public void AddPerson() { var repo = new AgeRangerRepository.Repo(); var testPerson = new AgeRangerEntities.Person { First = "test_first", Last = "test_last", Age = 23 }; repo.AddPerson(testPerson); // No ex thrown is pass. }
public void GetAllPeople_CountIncreasesAfterAddingPerson() { var repo = new AgeRangerRepository.Repo(); int beforeCount = repo.GetAllPeople().Count; var testPerson = new AgeRangerEntities.Person { First = "test_first", Last = "test_last", Age = 23 }; repo.AddPerson(testPerson); int afterCount = repo.GetAllPeople().Count; Assert.AreEqual(beforeCount, afterCount - 1); }
public void AddPerson_GetPersonByFirstNameReturnsAddedRecord() { string randomName = Guid.NewGuid().ToString(); var repo = new AgeRangerRepository.Repo(); var testPerson = new AgeRangerEntities.Person { First = randomName, Last = "test_last", Age = 2 }; var addResult = repo.AddPerson(testPerson); var person = repo.GetPersonByFirstName(randomName); Assert.AreEqual(person.First, testPerson.First); // While I'm here verify extra, that description of matched group is as expected. Assert.AreEqual(person.Group.Description, "Child"); }
public void AddPerson_GetPersonByLastNameReturnsAddedRecord() { string randomName = Guid.NewGuid().ToString(); var repo = new AgeRangerRepository.Repo(); var testPerson = new AgeRangerEntities.Person { First = "first_name", Last = randomName, Age = 100 }; var addResult = repo.AddPerson(testPerson); var person = repo.GetPersonByLastName(randomName); Assert.AreEqual(person.First, testPerson.First); // While I'm here verify extra, that age range was calc properly. Assert.IsTrue(person.Group.MaxAge > testPerson.Age); Assert.IsTrue(person.Group.MinAge <= testPerson.Age); }