示例#1
0
        public async Task FindByIdTest()
        {
            using var myContext = CreateMagasinDbContext();
            var repo    = new ArticleEFRepository(myContext);
            var article = await repo.FindById(3);

            article.Libelle.Should().Be("PC");
            article.Id.Should().Be(3);
        }
示例#2
0
        public async Task RemoveTest()
        {
            using (var myContext = CreateMagasinDbContext())
            {
                var repo    = new ArticleEFRepository(myContext);
                var article = await repo.FindById(4);

                repo.Remove(article);
                await repo.Save();
            }
            using (var myContext = CreateMagasinDbContext())
            {
                var repo     = new ArticleEFRepository(myContext);
                var elements = await repo.GetAll();

                elements.Should().HaveCount(3);
                elements.Any(e => e.Id == 4).Should().BeFalse();
            }
        }