public void Remove_ExistingClient_DeletesClientFromDatabase()
        {
            //Arrange
            var clients = new List <Client>()
            {
                new Client()
                {
                    Nom       = "Carange",
                    Prenom    = "Hugues",
                    Telephone = "418-123-4567"
                },
                new Client()
                {
                    Nom       = "Bob",
                    Prenom    = "Dylan",
                    Telephone = "418-098-7654"
                },
            };

            var itemsCountBefore = clients.Count;

            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Clients.AddRange(clients);
                apiDbContext.SaveChanges();
            }

            //Action
            _clientRepository.Delete(clients.ElementAt(1));

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Clients.ToList().Count.Should().Be(itemsCountBefore - 1);
            }
        }
        public void Delete_ExistingFacture_DeletesFactureFromDatabase()
        {
            //Arrange
            var client = new Client()
            {
                Nom       = "Carange",
                Prenom    = "Hugues",
                Telephone = "418-123-4567"
            };
            var groupe = new Groupe()
            {
                Nom    = "Sex Pistols",
                Cachet = 10000,
            };
            var contrat = new Contrat()
            {
                Groupe           = groupe,
                IdGroupe         = groupe.Id,
                Client           = client,
                IdClient         = client.Id,
                DateContrat      = new DateTime(2017, 12, 12),
                DatePresentation = new DateTime(2017, 11, 11),
                HeureDebut       = new DateTime(2017, 11, 11, 12, 24, 43),
                HeureFin         = new DateTime(2017, 11, 11, 12, 24, 44),
                Depot            = 11334,
                Cachet           = 2344,
                MontantFinal     = 23545
            };
            var factures = new List <Facture>()
            {
                new Facture()
                {
                    DateProduction = new DateTime(2017, 12, 12),
                    DatePaiement   = new DateTime(2017, 11, 11),
                    ModePaiement   = "Comptant",
                    Contrat        = contrat,
                    IdContrat      = contrat.Id
                },
                new Facture()
                {
                    DateProduction = new DateTime(2017, 12, 12),
                    DatePaiement   = new DateTime(2017, 11, 11),
                    ModePaiement   = "Debit",
                    Contrat        = contrat,
                    IdContrat      = contrat.Id
                },
            };

            var itemsCountBefore = factures.Count;

            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Factures.AddRange(factures);
                apiDbContext.SaveChanges();
            }

            //Action
            _factureRepository.Delete(factures.ElementAt(1));

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