Example #1
0
        public async Task InsertTest()
        {
            using (var myContext = CreateMagasinDbContext())
            {
                var repo       = new EtagereEFRepository(myContext);
                var newEtagere = new Etagere
                {
                    Id           = 5,
                    PoidsMaximum = 22000,
                    SecteurId    = 2
                };

                repo.Insert(newEtagere);
                await(repo.Save());
            }
            using (var myContext = CreateMagasinDbContext())
            {
                var repo     = new EtagereEFRepository(myContext);
                var elements = await repo.GetAll();

                elements.Should().HaveCount(5);
                elements.Any(e => e.Id == 5).Should().BeTrue();
                elements.Any(e => e.PoidsMaximum == 22000).Should().BeTrue();
            }
        }
Example #2
0
        public async Task UpdateTest()
        {
            using (var myContext = CreateMagasinDbContext())
            {
                var repo    = new EtagereEFRepository(myContext);
                var etagere = new Etagere
                {
                    Id           = 1,
                    PoidsMaximum = 26580,
                    SecteurId    = 2
                };

                repo.Update(etagere);
                await repo.Save();
            }
            using (var myContext = CreateMagasinDbContext())
            {
                var repo     = new EtagereEFRepository(myContext);
                var elements = await repo.GetAll();

                elements.Should().HaveCount(4);
                elements.Any(e => e.Id == 1).Should().BeTrue();
                elements.Any(e => e.PoidsMaximum == 26580).Should().BeTrue();
                elements.Any(e => e.PoidsMaximum == 15000).Should().BeFalse();
                elements.Any(e => e.SecteurId == 2).Should().BeTrue();
            }
        }
Example #3
0
        public async Task RemoveTest()
        {
            using (var myContext = CreateMagasinDbContext())
            {
                var repo    = new EtagereEFRepository(myContext);
                var etagere = await repo.FindById(1);

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

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