public void WhenDisasterIsNotFoundThrowArgumentException()
        {
            var underTst = new AdminService(mockService.Object);

            initializeDisasterCollection(disasterWithCommitments);
            initializeVolunteerCollection(personWithCommitments);
            initializeCommitmentCollection(commitment);

            var disaster = new Disaster
            {
                Id = -1,
                Name = "DoesNotExist"
            };
            underTst.GetVolunteers(disaster);
        }
        public void GetVolunteersForDate_DoesNotReturnDuplicatePeople_WhenCommitmentsOverlap()
        {
            var mockData = new Mock<IDataService>();
            var commitments = new List<Commitment>();
            commitments.Add(new Commitment { DisasterId = 42, StartDate = DateTime.Today.AddDays(-2), EndDate = DateTime.Today.AddDays(1), PersonId = 1 });
            commitments.Add(new Commitment { DisasterId = 42, StartDate = DateTime.Today.AddDays(-1), EndDate = DateTime.Today.AddDays(2), PersonId = 1 });
            mockData.Setup(x => x.Commitments).Returns(commitments.AsQueryable());
            var disasters = new List<Disaster>();
            disasters.Add(new Disaster { Id = 42, Name = "disaster", IsActive = true });
            mockData.Setup(x => x.Disasters).Returns(disasters.AsQueryable());
            var persons = new List<Person>();
            persons.Add(new Person { Id = 1, ClusterId = 2 });
            mockData.Setup(x => x.Persons).Returns(persons.AsQueryable());

            var underTest = new AdminService(mockData.Object);

            var actual = underTest.GetVolunteersForDate(42, DateTime.Today);

            Assert.AreEqual(1, actual.Count());
        }
        public void WhenVolunteersExistForMultipleDisastersReturnCorrectDisaster()
        {
            initializeDisasterCollection(disasterWithCommitments, disasterWithNoCommitments);
            initializeVolunteerCollection(personWithCommitments, personWithNoCommitments);

            var secondCommitment = new Commitment
            {
                DisasterId = disasterWithNoVolunteersID,
                Id = 102,
                PersonId = personWithNoCommitmentsID,
                StartDate = new DateTime(2013, 8, 15),
                EndDate = new DateTime(2013, 8, 20)
            };
            initializeCommitmentCollection(commitment, secondCommitment);

            var underTest = new AdminService(mockService.Object);

            var result = underTest.GetVolunteers(disasterWithCommitments);

            Assert.AreEqual(1, result.Count());
        }
        public void WhenVolunteerDontCommitReturnCommittedRecords()
        {
            initializeDisasterCollection(disasterWithCommitments);
            initializeVolunteerCollection(personWithCommitments, personWithNoCommitments);
            initializeCommitmentCollection(commitment);

            var underTest = new AdminService(mockService.Object);

            var result = underTest.GetVolunteers(disasterWithCommitments);

            Assert.AreEqual(1, result.Count());
        }
 public void WhenServiceIsNullConstructorThrowsExceptions()
 {
     var underTest = new AdminService(default(IDataService));
 }
        public void WhenOneVolunteerHasRegisteredReturnThatOneRecord()
        {
            initializeDisasterCollection(disasterWithCommitments);
            initializeVolunteerCollection(personWithCommitments);
            initializeCommitmentCollection(commitment);

            var underTest = new AdminService(mockService.Object);

            var result = underTest.GetVolunteers(disasterWithCommitments);

            Assert.AreEqual(1, result.Count());
        }
        public void WhenOneVolunteerHasRegisteredReturnNoRecordsInRange()
        {
            initializeDisasterCollection(disasterWithCommitments);
            initializeVolunteerCollection(personWithCommitments);
            initializeCommitmentCollection(commitment);

            var underTest = new AdminService(mockService.Object);

            var result = underTest.GetVolunteersForDate(disasterWithCommitments, new DateTime(2013, 08, 5));

            Assert.AreEqual(0, result.Count());
        }
        public void WhenNoVolunteersAreRegisteredReturnAnEmptyList()
        {
            var underTest = new AdminService(mockService.Object);

            initializeDisasterCollection(disasterWithNoCommitments);

            var result = underTest.GetVolunteers(disasterWithNoCommitments);
            Assert.IsFalse(result.Any());
        }
 public void WhenDisasterIsNullThrowNullArgumentException()
 {
     var underTest = new AdminService(mockService.Object);
     var result = underTest.GetVolunteers(default(Disaster));
 }
Example #10
0
 public AdminController(AdminService adminService)
 {
     _adminService = adminService;
 }