Ejemplo n.º 1
0
        public void TestDeletePerson()
        {
            using (var context = new School2Context(options))
            {
                var repository = new PersonRepository(context);
                repository.Delete(1);

                Assert.AreEqual(0, context.Person.Count());
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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");
                }
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public PersonRepository(School2Context context)
 {
     _context = context;
 }