Beispiel #1
0
        public void Should_GetPeopleBirthdayOnLeapYearEndOfMarch()
        {
            // Prepare
            List <DataAccess.Person> expectedResult = CreateFakePeople(1000);

            // Add at least one person who's birthday is on 29/03
            DateTime.TryParse("29/03/1988", out var leapYearMarchDay);
            var myTestPerson = new DataAccess.Person {
                Id = Guid.NewGuid(), FirstName = "John", LastName = "Doe", Email = "*****@*****.**", DateOfBirth = leapYearMarchDay
            };

            expectedResult.Add(myTestPerson);
            SeedPeopleInMemory(expectedResult);

            // Mock DateBusiness
            DateTime.TryParse("28/03/2020", out var parsedDate);
            _dateBusiness.Setup(d => d.GetDate()).Returns(parsedDate);
            _dateBusiness.Setup(d => d.IsLeapYear(parsedDate)).Returns(true);
            _dateBusiness.Setup(d => d.GetLeapYearMarchDay()).Returns(29);
            _dateBusiness.Setup(d => d.GetMarchMonthNumber()).Returns(3);

            // Act
            var actualResult = _peopleBusiness.GetBirthDayPeople();

            // Test
            Assert.Contains(actualResult, p => p == myTestPerson);
        }
Beispiel #2
0
 public static PersonViewModel ToPersonViewModel(this DataAccess.Person personEntity)
 {
     return(new PersonViewModel
     {
         PersonId = personEntity.PersonId,
         Username = personEntity.Username,
         Password = personEntity.Password
     });
 }
Beispiel #3
0
 private static Person MapDTAToBo(DataAccess.Person dta)
 {
     return(new Person()
     {
         Id = dta.PersonID,
         FirstName = dta.FirstName,
         FullName = $"{dta.FirstName} {dta.LastName}"
     });
 }
Beispiel #4
0
        public void Should_GetPeopleBirthdayToday()
        {
            // Prepare
            List <DataAccess.Person> expectedResult = CreateFakePeople(1000);

            // Add at least one person who's birthday is today
            var myTestPerson = new DataAccess.Person {
                Id = Guid.NewGuid(), FirstName = "John", LastName = "Doe", Email = "*****@*****.**", DateOfBirth = DateTime.Now.AddYears(-30)
            };

            expectedResult.Add(myTestPerson);
            SeedPeopleInMemory(expectedResult);

            // Mock DateBusiness
            _dateBusiness.Setup(d => d.GetDate()).Returns(DateTime.Now);
            _dateBusiness.Setup(d => d.IsLeapYear(DateTime.Now)).Returns(false);
            _dateBusiness.Setup(d => d.GetMarchMonthNumber()).Returns(3);

            // Act
            var actualResult = _peopleBusiness.GetBirthDayPeople();

            // Test
            Assert.Contains(actualResult, p => p == myTestPerson);
        }
Beispiel #5
0
 public Person(DataAccess.Person personDta)
 {
 }