public void MailAction_SmtpSender_Verify() { var mockMailSender = new Mock <IMailSender>(); var mockMailCopy = new Mock <IMailCopy>(); var mockNotify = new Mock <INotify>(); var mockPrint = new Mock <IPrint>(); mockMailSender.Setup(x => x.SendTo(It.IsAny <ConfigEntity>(), It.IsAny <MailEntity>(), It.IsAny <string>())).Returns(true); var mailAction = new Action.MailAction(mockMailSender.Object, mockMailCopy.Object, mockNotify.Object, mockPrint.Object); var res = mailAction.ActionSend(ConfigEntity, MailEntity, ConfigEntity.MailActions[3].ActTypeValue); Assert.That(res, Is.True); }
public void MailAction_Actions_WasCalled() { var mockMailSender = new Mock <IMailSender>(); var mockMailCopy = new Mock <IMailCopy>(); var mockNotify = new Mock <INotify>(); var mockPrint = new Mock <IPrint>(); var mailAction = new Action.MailAction(mockMailSender.Object, mockMailCopy.Object, mockNotify.Object, mockPrint.Object); mailAction.ActionSend(ConfigEntity, MailEntity, ConfigEntity.MailActions[3].ActTypeValue); mailAction.ActionCopy(ConfigEntity, MailEntity, ConfigEntity.MailActions[2].ActTypeValue); mailAction.ActionNotify(MailEntity); mailAction.ActionPrint(MailEntity); mockMailSender.Verify(x => x.SendTo(ConfigEntity, MailEntity, ConfigEntity.MailActions[3].ActTypeValue), Times.Once()); mockMailCopy.Verify(x => x.CopyTo(ConfigEntity, MailEntity, ConfigEntity.MailActions[2].ActTypeValue), Times.Once()); mockNotify.Verify(x => x.NotifyTo(MailEntity), Times.Once()); mockPrint.Verify(x => x.PrintTo(MailEntity), Times.Once()); }