public void WhenNoCommitmentsExistEmptyCollectionIsReturned()
        {
            var moqDataService = new Mock <IDataService>();

            moqDataService.Setup(ds => ds.Commitments)
            .Returns(new List <Commitment>().AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id        = 1,
                FirstName = "test",
                LastName  = "tester"
            };
            var disaster = new Disaster
            {
                Id       = 1,
                Name     = "test",
                IsActive = true
            };

            moqDataService.Setup(ds => ds.Disasters)
            .Returns(new List <Disaster>
            {
                disaster
            }.AsQueryable());

            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);

            Assert.IsTrue(results.Count() == 0);
        }
        public void WhenQueryingReturnCommitmentsOnlyForThisDisaster()
        {
            var moqDataService = new Mock <IDataService>();
            var disaster       = new Disaster
            {
                Id       = 1,
                Name     = "test",
                IsActive = true
            };
            var disaster2 = new Disaster
            {
                Id       = 2,
                Name     = "test",
                IsActive = true
            };

            moqDataService.Setup(ds => ds.Disasters)
            .Returns(new List <Disaster>
            {
                disaster,
                disaster2
            }.AsQueryable());

            moqDataService.Setup(ds => ds.Commitments)
            .Returns(new List <Commitment>
            {
                new Commitment
                {
                    DisasterId = 1,
                    Id         = 1,
                    PersonId   = 1,
                    StartDate  = new DateTime(2013, 8, 1),
                    EndDate    = new DateTime(2013, 9, 1),
                    Disaster   = disaster
                },
                new Commitment
                {
                    DisasterId = 2,
                    Id         = 2,
                    PersonId   = 1,
                    StartDate  = new DateTime(2013, 8, 1),
                    EndDate    = new DateTime(2013, 9, 1),
                    Disaster   = disaster2
                }
            }.AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id        = 1,
                FirstName = "test",
                LastName  = "tester"
            };

            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);

            Assert.AreEqual(1, results.Count());
        }
        public void WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException()
        {
            var moqDataService = new Mock <IDataService>();
            var underTest      = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id        = 1,
                FirstName = "test",
                LastName  = "tester"
            };

            var results = underTest.RetrieveCommitmentsForDisaster(person, default(Disaster));
        }
        public void WhenQueriedActiveCommitmentsAreReturned()
        {
            var moqDataService = new Mock <IDataService>();
            var disaster       = new Disaster
            {
                Id       = 1,
                Name     = "test",
                IsActive = true
            };

            moqDataService.Setup(ds => ds.Disasters)
            .Returns(new List <Disaster>
            {
                disaster
            }.AsQueryable());

            moqDataService.Setup(ds => ds.Commitments)
            .Returns(new List <Commitment>
            {
                new Commitment
                {
                    DisasterId = 1,
                    Id         = 1,
                    PersonId   = 1,
                    StartDate  = new DateTime(2013, 8, 1),
                    EndDate    = new DateTime(2013, 9, 1),
                    Disaster   = disaster
                }
            }.AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id        = 1,
                FirstName = "test",
                LastName  = "tester"
            };

            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);

            Assert.IsTrue(results.Count() == 1);
            Assert.IsTrue(results.Single().Id == 1);
        }
        public void WhenQueryingReturnCommitmentsOnlyForThisUser()
        {
            var moqDataService = new Mock<IDataService>();
            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = true
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());

            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>
                {
                    new Commitment
                    {
                        DisasterId=1,
                        Id = 1,
                        PersonId=1,
                        StartDate=new DateTime(2013, 8, 1),
                        EndDate = new DateTime(2013, 9, 1),
                        Disaster=disaster
                    },
                    new Commitment
                    {
                        DisasterId=1,
                        Id = 2,
                        PersonId=2,
                        StartDate=new DateTime(2013, 8, 1),
                        EndDate = new DateTime(2013, 9, 1)
                    }
                }.AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };
            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);
            Assert.IsTrue(results.Count() == 1);
        }
        public void WhenNoCommitmentsExistEmptyCollectionIsReturned()
        {
            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>().AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };
            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = true
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());

            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);
            Assert.IsTrue(results.Count() == 0);
        }
        public void WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException()
        {
            var moqDataService = new Mock<IDataService>();
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };

            var results = underTest.RetrieveCommitmentsForDisaster(person, default(Disaster));
        }