I have handler interface and its interface implemented class
public class Microsoft365Handler : IMicrosoft365Handler
{
protected internal void DeleteDocument()
{
}
}
And handler gets called from another class like below
internal class Microsoft365Agent : AgentBase, IMicrosoft365Agent
{
public void DeleteDocument(Microsoft365Model microsoft365Model)
{
var client = Create<Microsoft365Handler>();
client.DeleteDocument();
}
}
below is my test case
[TestMethod]
public void Microsoft365Agent_DeleteDocument_Success()
{
// Create a fake authentication context.
Microsoft365Model microsoft365Model = new Microsoft365Model
{
Id = 1,
AccessToken = "ABCSSDSDSD",
RefreshToken = "JGJIBJKBKJB",
ClientId = "HJBJKBHBKHBK",
ClientSecret = "HHUSDHDBSD",
RemoteFolder = "NORTHGATE/Test",
TenantId = "KJJKBJBKB",
UserId = "imasys",
UserEmailAddress = "",
DocGuid = CommonHelper.OFFICE365UPLOADEDFILE,
DocumentFilePath = "",
FileName = "Test.Docx",
LastTokenRefreshDate = DateTime.Now,
Office365EmailAddress = "",
UploadedDocumentUrl = ""
};
try
{
using (var agent = AgentFactory.Create<IMicrosoft365Agent>(securityInfo))
{
agent.DeleteDocument(microsoft365Model);
}
return;
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}
its called delete method from concrete class but when for test cases I not able to create mock of handler method as its mark as protected internal.
We have unity to implement unit test cases so that we can have fake classes to handle unit test case but in this particular method I want redirect hander method to another fake class but I cant change its access modifiers (cant upgrade to c#8.0). I there any way to re-design or write test case?