Exemplo n.º 1
0
        public void TestGet()
        {
            var repo = new CareerRepository(new MoviesContext());

            Career[] careers = new Career[5];
            for (int i = 0; i < 5; i++)
            {
                careers[i] = new Career {
                    Id = Guid.NewGuid(), Title = "testGetCareer" + i
                };
                repo.Insert(careers[i]);
            }
            repo.Save();

            var listOfCareers = repo.Get(c => c.Title.StartsWith("testGetCareer"));
            int j             = 0;

            Assert.AreEqual(listOfCareers.Count(), 5);
            for (int i = 0; i < 5; i++)
            {
                Assert.NotNull(listOfCareers.SingleOrDefault(c => c.Title == careers[j].Title));
            }

            for (int i = 0; i < 5; i++)
            {
                repo.Delete(careers[i]);
            }
            repo.Save();
        }
Exemplo n.º 2
0
        public void TestGet()
        {
            var repo = new CareerRepository(new MoviesContext());
            Career[] careers = new Career[5];
            for (int i = 0; i < 5; i++)
            {
                careers[i] = new Career { Id = Guid.NewGuid(), Title = "testGetCareer" + i };
                repo.Insert(careers[i]);
            }
            repo.Save();

            var listOfCareers = repo.Get(c => c.Title.StartsWith("testGetCareer"));
            int j = 0;

            Assert.AreEqual(listOfCareers.Count(), 5);
            for (int i = 0; i < 5; i++)
            {
                Assert.NotNull(listOfCareers.SingleOrDefault(c => c.Title == careers[j].Title));
            }

            for (int i = 0; i < 5; i++)
            {
                repo.Delete(careers[i]);
            }
            repo.Save();
        }
Exemplo n.º 3
0
        public void TestDelete()
        {
            var repo = new CareerRepository(new MoviesContext());
            var career = new Career { Id = Guid.NewGuid(), Title = "testDeleteCareer" };
            repo.Insert(career);
            repo.Save();

            repo.Delete(career.Id);
            repo.Save();

            var sameCareer = repo.GetById(career.Id);
            Assert.IsNull(sameCareer);
        }
Exemplo n.º 4
0
        public void TestUpdate()
        {
            var repo = new CareerRepository(new MoviesContext());
            var career = new Career { Id = Guid.NewGuid(), Title = "testUpdateCareer" };
            repo.Insert(career);
            repo.Save();

            career.Title = "UpdatedCareer";
            repo.Update(career);
            repo.Save();
            var sameCareer = repo.GetById(career.Id);
            Assert.AreEqual(career.Title, sameCareer.Title);

            repo.Delete(career);
            repo.Save();
        }
Exemplo n.º 5
0
        public void TestDelete()
        {
            var repo   = new CareerRepository(new MoviesContext());
            var career = new Career {
                Id = Guid.NewGuid(), Title = "testDeleteCareer"
            };

            repo.Insert(career);
            repo.Save();

            repo.Delete(career.Id);
            repo.Save();

            var sameCareer = repo.GetById(career.Id);

            Assert.IsNull(sameCareer);
        }
Exemplo n.º 6
0
        public void TestUpdate()
        {
            var repo   = new CareerRepository(new MoviesContext());
            var career = new Career {
                Id = Guid.NewGuid(), Title = "testUpdateCareer"
            };

            repo.Insert(career);
            repo.Save();

            career.Title = "UpdatedCareer";
            repo.Update(career);
            repo.Save();
            var sameCareer = repo.GetById(career.Id);

            Assert.AreEqual(career.Title, sameCareer.Title);

            repo.Delete(career);
            repo.Save();
        }
Exemplo n.º 7
0
 public void DeleteCareer(int id)
 {
     CareerRepository.Delete(id);
 }