The following test that verifies a call to another function fails every once in a while when run as a group. I've used the Moq framework to perform the mocking. Could someone help regarding this? I have no global variables or shared variables.
public void CallOnceNotificationBLForEmailSendTest()
{
Mock<INotificationBL> notificationBLmock = new Mock<INotificationBL>();
Item processItem = CreateItem(DateTime.Now, ItemDates.End, Process, "TestProcess");
SaveItem(processItem);
Item mailRecipientItem1 = CreateItem(DateTime.Now, ItemDates.End, MailRecipient, "TestMailRecipient1");
mailRecipientItem1.SetPropertyValue("EMAIL", DateTime.Now, ItemDates.End, "xyz@slb.com");
SaveItem(mailRecipientItem1);
ItemLink proc_mailrec = new ItemLink("PRC_RECIPIENT", processItem, mailRecipientItem1, DateTime.Now,
ItemDates.End);
SaveLink(proc_mailrec);
ProcessEmailBL processEmailBL = new ProcessEmailBL();
processEmailBL.NotificationBL = notificationBLmock.Object;
ProcessParameter processParameter = new ProcessParameter
{
StartDate = ItemDates.Start,
EndDate = ItemDates.End,
ProcessItem = processItem
};
processEmailBL.SendEmail(processParameter, processItem, It.IsAny<DateTime>(), It.IsAny<string>(),
It.IsAny<string>());
notificationBLmock.Verify(
x => x.SendAndQueueMail(It.IsAny<List<string>>(), It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<Attachment>(), It.IsAny<string>()), Times.Exactly(1));
}
Aucun commentaire:
Enregistrer un commentaire