public void TestDeletePerson() { using (var context = new School2Context(options)) { var repository = new PersonRepository(context); repository.Delete(1); Assert.AreEqual(0, context.Person.Count()); } }
public void TestAddPerson() { using (var context = new School2Context(options)) { Assert.AreEqual(1, context.Person.Count()); Assert.AreEqual("TestStudent", context.Person.Single().LastName); var repository = new PersonRepository(context); } }
public void TestInitialization() { options = new DbContextOptionsBuilder <School2Context>() .UseInMemoryDatabase(databaseName: "InMemoryTestDb") .Options; using (var context = new School2Context(options)) { var repository = new PersonRepository(context); if (context.Person.Count() == 0) { repository.Add("TestStudent", "Test", null, null, "Student"); } } }
public void TestGetInstructors() { using (var context = new School2Context(options)) { var repository = new PersonRepository(context); repository.Add("TestInstructor", "Test", null, null, "Instructor"); } using (var context = new School2Context(options)) { var repository = new PersonRepository(context); var insructors = repository.GetInstructors(); Assert.AreEqual(1, insructors.Count()); Assert.AreEqual("TestInstructor", insructors.First().LastName); } }
public PersonRepository(School2Context context) { _context = context; }