public void SendEmail_ShouldAddDegugEmailInBcc_IfItIsProvidedInSettings()
        {
            // Arrange
            var mockMailSender = new Mock<IMailSender>();
            var stubSettings = new Mock<ISettings>();
            var stubFileHelper = new Mock<IFileHelper>();

            mockMailSender.Setup(m => m.Send(It.Is<MailMessage>(mes => mes.Bcc.Any(bcc => bcc.Address.Equals("*****@*****.**"))))).Verifiable();
            stubSettings.Setup(s => s.DebugEmail).Returns("*****@*****.**");

            // Act
            var mailHelper = new MailHelper(mockMailSender.Object, stubSettings.Object, stubFileHelper.Object);
            mailHelper.SendEmail("*****@*****.**");

            // Assert
            mockMailSender.Verify();
        }
        public void SendEmail_ShouldSendBodyWithSubjectProvidedInSettings()
        {
            // Arrange
            var mockMailSender = new Mock<IMailSender>();
            var stubSettings = new Mock<ISettings>();
            var stubFileHelper = new Mock<IFileHelper>();

            stubSettings.Setup(s => s.Subject).Returns("mail subject");

            mockMailSender.Setup(m => m.Send(It.Is<MailMessage>(mes => mes.Subject.Equals("mail subject")))).Verifiable();

            // Act
            var mailHelper = new MailHelper(mockMailSender.Object, stubSettings.Object, stubFileHelper.Object);
            mailHelper.SendEmail("*****@*****.**");

            // Assert
            mockMailSender.Verify();
        }
        public void SendEmail_ShouldSendBodyAsHtml_IfItIsSettedUpInSettings()
        {
            // Arrange
            var mockMailSender = new Mock<IMailSender>();
            var stubSettings = new Mock<ISettings>();
            var stubFileHelper = new Mock<IFileHelper>();

            stubSettings.Setup(s => s.UseHtmlBody).Returns(true);

            mockMailSender.Setup(m => m.Send(It.Is<MailMessage>(mes => mes.IsBodyHtml))).Verifiable();

            // Act
            var mailHelper = new MailHelper(mockMailSender.Object, stubSettings.Object, stubFileHelper.Object);
            mailHelper.SendEmail("*****@*****.**");

            // Assert
            mockMailSender.Verify();
        }
        public void SendEmail_ShouldUseMessageFromFile_IfGetBodyFromFileIsTrue()
        {
            // Arrange
            var mockMailSender = new Mock<IMailSender>();
            var stubSettings = new Mock<ISettings>();
            var stubFileHelper = new Mock<IFileHelper>();

            stubSettings.Setup(s => s.GetBodyFromFile).Returns(true);
            stubFileHelper.Setup(f => f.ReadText(It.IsAny<string>())).Returns("message body from file");

            mockMailSender.Setup(m => m.Send(It.Is<MailMessage>(mes => mes.Body.Equals("message body from file")))).Verifiable();

            // Act
            var mailHelper = new MailHelper(mockMailSender.Object, stubSettings.Object, stubFileHelper.Object);
            mailHelper.SendEmail("*****@*****.**");

            // Assert
            mockMailSender.Verify();
        }
        public void SendEmail_ShouldSendToAddressProvidedInParametr()
        {
            // Arrange
            var mockMailSender = new Mock<IMailSender>();
            var stubSettings = new Mock<ISettings>();
            var stubFileHelper = new Mock<IFileHelper>();

            mockMailSender.Setup(m => m.Send(It.Is<MailMessage>(mes => mes.To.Any(to => to.Address.Equals("*****@*****.**"))))).Verifiable();

            // Act
            var mailHelper = new MailHelper(mockMailSender.Object, stubSettings.Object, stubFileHelper.Object);
            mailHelper.SendEmail("*****@*****.**");

            // Assert
            mockMailSender.Verify();
        }