Beispiel #1
0
        public void SetUp()
        {
            _houseKeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };

            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _fileName           = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _fileName);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HouseKeeperService(
                unitOfWork.Object,
                _statementGenerator.Object,
                _emailSender.Object,
                _messageBox.Object);
        }
Beispiel #2
0
		public void SendStatementEmails_WhenCalled_GenerateStatements()
		{
			//mock a unit of work and return a list of 
			//house keeper in memory
			
			var unitOfWork = new Mock<IUnitOfWork>();
			unitOfWork.Setup(uow => uow.Query<HouseKeeper>()).Returns (new List<HouseKeeper>
			{
				new HouseKeeper { Email="a", FullName="a", Oid=1,StatementEmailBody = "c"
			}.AddQueryable());
			
			var statementGenerator = new Mock<IStatementGenerator>();
			var emailSender = new Mock<IEmailSender>();
			var messageBox = new Mock<IXtraMEssageBox();
			
			var service = new HouseKeeperService(
				unitOfWork.Object,
				statementGenerator.Object,
				emailSender.Object,
				messageBox.Object);
				
			service.SendStatementEmails ( new DateTime(2017,1,1));
			
			statementGenerator.Verify( sg => sg.SaveStatement(1,"b", (new DateTime(2017,1,1))));
			//Verify has a second argument that indicates how many time the first argument should be called
			//Times.Never, AtLeastOnce, AtLeast, AtMost, AtMostOnce, Between, Exactly, Never, Once
			//example:
			statementGenerator.Verify( sg => sg.SaveStatement(1,"b", (new DateTime(2017,1,1))), Times.Never);
			
			}
		}
Beispiel #3
0
        public void SetUp()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };
            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(uOw => uOw.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable());

            _statementGenerator = new Mock <IStatementGenerator>();
            _emailSender        = new Mock <IEmailSender>();
            _msgBox             = new Mock <IXtraMessageBox>();
            _service            = new HouseKeeperService(_unitOfWork.Object, _statementGenerator.Object, _emailSender.Object, _msgBox.Object);
        }
Beispiel #4
0
        public void SetUp()
        {
            _keeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "something"
            };

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(un => un.Query <Housekeeper>()).Returns(new List <Housekeeper> {
                _keeper
            }.AsQueryable());

            _statementFileName  = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator.Setup(sg => sg.SaveStatement(_keeper.Oid, _keeper.FullName, date))
            .Returns(() => _statementFileName);

            _emailSender    = new Mock <IEmailSender>();
            _xtraMessageBox = new Mock <IXtraMessageBox>();
            _services       = new HouseKeeperService(_unitOfWork.Object, _statementGenerator.Object, _emailSender.Object, _xtraMessageBox.Object);
        }