Exemplo n.º 1
0
        public void Delete_ExistingGroupe_DeletesGroupeFromDatabase()
        {
            //Arrange
            var groupes = new List <Groupe>()
            {
                new Groupe()
                {
                    Nom    = "Jimmi Hendrix",
                    Cachet = 10000,
                },
                new Groupe()
                {
                    Nom    = "The Animals",
                    Cachet = 5000,
                },
            };

            var itemsCountBefore = groupes.Count;

            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Groupes.AddRange(groupes);
                apiDbContext.SaveChanges();
            }

            //Action
            _groupeRepository.Delete(groupes.ElementAt(1));

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Groupes.ToList().Count.Should().Be(itemsCountBefore - 1);
            }
        }
Exemplo n.º 2
0
        public void Delete_ExistingArtiste_DeletesArtisteFromDatabase()
        {
            //Arrange
            var artistes = new List <Artiste>()
            {
                new Artiste()
                {
                    Nom        = "Carange",
                    Prenom     = "Hugues",
                    Telephone  = "418-123-4567",
                    NAS        = "ABC-1D2-1G5",
                    NomDeScene = "Croustillant"
                },
                new Artiste()
                {
                    Nom        = "Bob",
                    Prenom     = "Dylan",
                    Telephone  = "418-098-7654",
                    NAS        = "AL2-1G4-1A8",
                    NomDeScene = "Sauce"
                },
            };

            var itemsCountBefore = artistes.Count;

            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Artistes.AddRange(artistes);
                apiDbContext.SaveChanges();
            }

            //Action
            _artisteRepository.Delete(artistes.ElementAt(1));

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Artistes.ToList().Count.Should().Be(itemsCountBefore - 1);
            }
        }