Example #1
0
        public void SendStatementEmails_EmialIsInvalid_ShouldNotGenerateStatement(string email)
        {
            _houseKeeper.Email = email;
            _housekeeperHelper.SendStatementEmails(_sendingTime);

            _statementGenerator.Verify(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _sendingTime), Times.Never);
        }
Example #2
0
        public void SendStatementEmails_EmailSendingFails_DisplayAMessageBox()
        {
            _statementFileName = "FileName";
            _emailSender.Setup(es => es.EmailFile(
                                   It.IsAny <string>(),
                                   It.IsAny <string>(),
                                   It.IsAny <string>(),
                                   It.IsAny <string>()
                                   )).Throws <Exception>();

            _service.SendStatementEmails(_statementDate);

            _messageBox.Verify(mb => mb.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButtons.OK));
        }
Example #3
0
        public void SendStatementEmails_HousekeepersEmailIsNullOrWhitespace_ShouldNotGenerateStatement(string email)
        {
            _housekeeper.Email = email;

            HousekeeperHelper.SendStatementEmails(_statementDate,
                                                  _unitOfWorkMock.Object, _housekeeperHelperRepositoryMock.Object);

            _housekeeperHelperRepositoryMock.Verify(hhr => hhr.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate), Times.Never);
        }
Example #4
0
        public void SendStatementEmails_WhenCalled_GenerateStatements()
        {
            _housekeeper.Email = "*****@*****.**";

            HousekeeperHelper.SendStatementEmails(_statementDate,
                                                  _unitOfWorkMock.Object, _housekeeperHelperRepositoryMock.Object);

            _housekeeperHelperRepositoryMock.Verify(hhr => hhr.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate));
        }
Example #5
0
        public void SendStatementEmails_WhenCalled_EmailTheStatement()
        {
            _housekeeper.Email = "*****@*****.**";

            HousekeeperHelper.SendStatementEmails(_statementDate,
                                                  _unitOfWorkMock.Object, _housekeeperHelperRepositoryMock.Object);

            _housekeeperHelperRepositoryMock.Verify(hhr => hhr.EmailFile(_housekeeper.Email, _housekeeper.StatementEmailBody,
                                                                         _statementFilename, It.IsAny <string>()));
        }
Example #6
0
        public void SendStatementEmails_StatementFilenameIsEmptyOrWhiteSpaceOrNull_EmailTheStatement(string filename)
        {
            _housekeeper.Email = "*****@*****.**";

            _statementFilename = filename;

            HousekeeperHelper.SendStatementEmails(_statementDate,
                                                  _unitOfWorkMock.Object, _housekeeperHelperRepositoryMock.Object);

            _housekeeperHelperRepositoryMock.Verify(hhr => hhr.EmailFile(It.IsAny <string>(), It.IsAny <string>(),
                                                                         _statementFilename, It.IsAny <string>()), Times.Never);
        }
        public void SendStatementEmails_StatementFoundFileSaved_ShouldCallSaveStatementShouldCallEmailAndReturnsTrue()
        {
            var statementGenerator = new Mock <IStatementGenerator>();

            statementGenerator.Setup(s => s.SaveStatement(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>())).Returns("saved");
            var emailer = new Mock <IEmailer>();

            emailer.Setup(e => e.Email(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));

            var result = HousekeeperHelper.SendStatementEmails(unitOfWork.Object, statementGenerator.Object, emailer.Object, DateTime.Now);

            unitOfWork.Verify(u => u.Query <Housekeeper>());
            emailer.Verify(e => e.Email(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            statementGenerator.Verify(s => s.SaveStatement(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>()));
            Assert.That(result, Is.EqualTo(true));
        }
        public void SendStatementEmails_StatementNotFound_ShouldReturnsFalse()
        {
            var statementGenerator = new Mock <IStatementGenerator>();

            statementGenerator.Setup(s => s.SaveStatement(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>())).Returns("");
            var emailer = new Mock <IEmailer>();

            emailer.Setup(e => e.Email(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));
            unitOfWork = new Mock <IUnitOfWork>();
            unitOfWork.Setup(u => u.Query <Housekeeper>()).Returns(new List <Housekeeper>().AsQueryable());
            var result = HousekeeperHelper.SendStatementEmails(unitOfWork.Object, statementGenerator.Object, emailer.Object, DateTime.Now);

            unitOfWork.Verify(u => u.Query <Housekeeper>());
            //emailer.Verify(e => e.Email(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()));
            //statementGenerator.Verify(s => s.SaveStatement(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>()));
            Assert.That(result, Is.EqualTo(false));
        }
        public void SendStatementEmails_WhenCalled_SendsEmails()
        {
            // Arrange
            var utilities = new Mock <IHouseKeeperUtilities>();

            utilities.Setup(u => u.SaveStatement(It.IsAny <int>(), It.IsAny <string>(), DateTime.Today)).Returns("abc");

            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(u => u.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                new Housekeeper {
                    Email = "a", StatementEmailBody = "b", FullName = "c", Oid = 1
                },
                new Housekeeper {
                    Email = "a", StatementEmailBody = "b", FullName = "c", Oid = 2
                }
            }.AsQueryable());

            HousekeeperHelper.SendStatementEmails(DateTime.Today, utilities.Object, unitOfWork.Object);

            utilities.Verify(u => u.SaveStatement(It.IsAny <int>(), It.IsAny <string>(), DateTime.Today), Times.Exactly(2));
            utilities.Verify(u => u.EmailFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2));
        }
Example #10
0
 public void SendStateEmail_WhenCalled_GeneratesEmailStatements()
 {
     _service.SendStatementEmails(_serviceDate);
     _mockStatement.Verify(s => s.SaveStatement(_testHouseKeeper.Oid, _testHouseKeeper.FullName, _serviceDate));
 }
Example #11
0
        public void SendStatementEmails_WhenCalled_GeneratesStatementReport()
        {
            _service.SendStatementEmails(_statementDate);

            _statementGenerator.Verify(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate));
        }
        public void SendStatementEmails_WhenCalled_GenerateStatements()
        {
            _service.SendStatementEmails(_statementDate);

            _houseKeeperFunctions.Verify(hk => hk.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate));
        }
        public void SendStatementEmails_WhenCalled_GenerateStatements()
        {
            _housekeeperHelper.SendStatementEmails(_statementDate);

            _statementGenerator.Verify(sg => sg.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate));
        }