Exemplo n.º 1
0
        public void Update_ExistingClient_UpdateClientFromDatabase()
        {
            //Arrange
            var clientsToAdd = new List <Client>()
            {
                new Client()
                {
                    Nom       = "Carange",
                    Prenom    = "Hugues",
                    Telephone = "418-123-4567"
                },

                new Client()
                {
                    Nom       = "Bob",
                    Prenom    = "Dylan",
                    Telephone = "418-098-7654"
                }
            };

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

            //Action
            var client = _clientRepository.GetById(clientsToAdd.ElementAt(0).Id);

            client.Telephone.Equals("418-123-1234");
            _clientRepository.Update(client);

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Clients.ToList().First().Telephone.Equals("418-123-1234");
            }
        }
Exemplo n.º 2
0
        public void Update_ExistingFacture_UpdateFactureFromDatabase()
        {
            //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 facturesToAdd = 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
                },
            };

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

            //Action
            var facture  = _factureRepository.GetById(facturesToAdd.ElementAt(0).Id);
            var dateTime = new DateTime(2017, 1, 9);

            facture.DatePaiement.Equals(dateTime);
            _factureRepository.Update(facture);

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Factures.ToList().First().DatePaiement.Equals(dateTime);
            }
        }
Exemplo n.º 3
0
        public void Update_ExistingContrat_UpdateContratFromDatabase()
        {
            //Arrange
            var client = new Client()
            {
                Nom       = "Carange",
                Prenom    = "Hugues",
                Telephone = "418-123-4567"
            };
            var groupe = new Groupe()
            {
                Nom    = "Sex Pistols",
                Cachet = 10000,
            };
            var contratsToAdd = new List <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
                },
                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            = 114,
                    Cachet           = 24,
                    MontantFinal     = 235
                },
            };

            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Contrats.AddRange(contratsToAdd);
                apiDbContext.SaveChanges();
            }

            //Action
            var contrat = _contratRepository.GetById(contratsToAdd.ElementAt(0).Id);

            contrat.MontantFinal.Equals(2345);
            _contratRepository.Update(contrat);

            // Assert
            using (var apiDbContext = _dbContextFactory.Create())
            {
                apiDbContext.Contrats.ToList().First().MontantFinal.Equals(2345);
            }
        }