Exemplo n.º 1
0
        public void Repository_DeleteCascade()
        {
            var advertRepo = new AdvertRepo(appContext);

            Assert.Equal(2, appContext.Adverts.Count());
            Assert.Equal(2, appContext.AdvertDetails.Count());
            Assert.Equal(4, appContext.AdPictures.Count());

            advertRepo.Delete(6);
            advertRepo.Save();

            Assert.Equal(1, appContext.Adverts.Count());
            Assert.Equal(1, appContext.AdvertDetails.Count());
            Assert.Equal(2, appContext.AdPictures.Count());
        }
Exemplo n.º 2
0
        public void Create()
        {
            Advert advert = GetAdvert();

            AdvertRepo repo = new AdvertRepo(appContext);

            repo.Create(advert);
            repo.Save();

            IEnumerable <Advert> adverts = repo.FindAll();
            Advert ad = adverts.FirstOrDefault(x => x.ID == 8);



            Assert.Equal(8, adverts.Count());
            Assert.Equal("Black Toyota for sale", ad.Detail.Title);
            Assert.Equal(2, ad.Detail.AdPictures.Count());
        }