public void AssignToVolunteer_BeginDateGreaterThanEndDate()
        {
            var startDate = new DateTime(2013, 6, 13);
            var endDate   = startDate.Subtract(TimeSpan.FromDays(1));

            _disasterService.AssignToVolunteer(0, 0, startDate, endDate);
        }
Пример #2
0
        public void AssignToVolunteer_StartDateIsWithinExistingCommitment()
        {
            var             moqDataService = new Mock <IDataService>();
            DisasterService service        = new DisasterService(moqDataService.Object);

            var commitments = new List <Commitment>()
            {
                new Commitment()
                {
                    StartDate  = new DateTime(2013, 6, 10),
                    EndDate    = new DateTime(2013, 6, 15),
                    DisasterId = 2
                }
            };
            var disasters = new List <Disaster>()
            {
                new Disaster()
                {
                    Id = 2, IsActive = true
                }
            };

            moqDataService.Setup(s => s.Commitments).Returns(commitments.AsQueryable());
            moqDataService.Setup(s => s.Disasters).Returns(disasters.AsQueryable());

            service.AssignToVolunteer(new Disaster(), new Person(), new DateTime(2013, 6, 11), new DateTime(2013, 6, 20));
        }
Пример #3
0
        public void AssignToVolunteer_NullPerson()
        {
            var             moqDataService = new Mock <IDataService>();
            DisasterService service        = new DisasterService(moqDataService.Object);

            service.AssignToVolunteer(new Disaster(), null, new DateTime(2014, 01, 01), new DateTime(2014, 02, 02));
        }
Пример #4
0
        public void AssignToVolunteer_BeginDateGreaterThanEndDate()
        {
            var             moqDataService = new Mock <IDataService>();
            DisasterService service        = new DisasterService(moqDataService.Object);

            service.AssignToVolunteer(new Disaster(), new Person(), new DateTime(2013, 6, 13), new DateTime(2013, 5, 10));
        }
Пример #5
0
        public void AssignToVolunteer_Valid()
        {
            var moqDataService = new Mock <IDataService>();

            moqDataService.Setup(s => s.AddCommitment(It.IsAny <Commitment>())).Returns(new Commitment()
            {
                Id         = 1,
                PersonId   = 5,
                DisasterId = 10,
                StartDate  = new DateTime(2014, 01, 01),
                EndDate    = new DateTime(2014, 01, 01)
            });
            DisasterService service = new DisasterService(moqDataService.Object);

            var actual = service.AssignToVolunteer(new Disaster()
            {
                Id = 10, Name = "A disaster"
            },
                                                   new Person()
            {
                Id = 5, Email = "*****@*****.**"
            },
                                                   new DateTime(2013, 01, 01), new DateTime(2013, 02, 01));

            Assert.AreEqual(1, actual.Id);
            Assert.AreEqual(5, actual.PersonId);
            Assert.AreEqual(10, actual.DisasterId);
            Assert.AreEqual("1/1/2014", actual.StartDate.ToShortDateString());
        }
Пример #6
0
        public void AssignToVolunteer_NullDisaster()
        {
            var moqDataService = new Mock<IDataService>();
            DisasterService service = new DisasterService(moqDataService.Object);

            service.AssignToVolunteer(null, new Person(), new DateTime(2014, 01, 01), new DateTime(2014, 02, 02));
        }
Пример #7
0
        public void AssignToVolunteer_BeginDateGreaterThanEndDate()
        {
            var moqDataService = new Mock<IDataService>();
            DisasterService service = new DisasterService(moqDataService.Object);

            service.AssignToVolunteer(new Disaster(), new Person(), new DateTime(2013, 6, 13), new DateTime(2013, 5, 10));
        }
Пример #8
0
        public void AssignToVolunteer_EndDateIsWithinExistingCommitment()
        {
            var moqDataService = new Mock<IDataService>();
            DisasterService service = new DisasterService(moqDataService.Object);

            var commitments = new List<Commitment>() {
                new Commitment() {
                    StartDate = new DateTime(2013, 6, 10),
                    EndDate = new DateTime(2013, 6, 15),
                    DisasterId = 2
                }
            };
            var disasters = new List<Disaster>() { new Disaster() { Id = 2, IsActive = true } };

            moqDataService.Setup(s => s.Commitments).Returns(commitments.AsQueryable());
            moqDataService.Setup(s => s.Disasters).Returns(disasters.AsQueryable());

            service.AssignToVolunteer(new Disaster(), new Person(), new DateTime(2013, 6, 5), new DateTime(2013, 6, 12));
        }
Пример #9
0
        public void AssignToVolunteer_Valid()
        {
            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.AddCommitment(It.IsAny<Commitment>())).Returns(new Commitment()
            {
                Id = 1,
                PersonId = 5,
                DisasterId = 10,
                StartDate = new DateTime(2014, 01, 01),
                EndDate = new DateTime(2014, 01, 01)
            });
            DisasterService service = new DisasterService(moqDataService.Object);

            var actual = service.AssignToVolunteer(new Disaster() { Id = 10, Name = "A disaster" },
                new Person() { Id = 5, Email = "*****@*****.**" },
                new DateTime(2013, 01, 01), new DateTime(2013, 02, 01));

            Assert.AreEqual(1, actual.Id);
            Assert.AreEqual(5, actual.PersonId);
            Assert.AreEqual(10, actual.DisasterId);
            Assert.AreEqual("1/1/2014", actual.StartDate.ToShortDateString());
        }