public void TPFact_FactureEntete_TestTrue_CreationFactureAvecNomClientStringEmpty() { try { #region Arrange var factureEntete = FactureBuilder.GenererFactureEntete(string.Empty, SingletonXpo.Instance.GetConditionPaiement()); SingletonXpo.Instance.CommitTransaction(factureEntete); #endregion #region Act var factureEnteteBack = SingletonXpo.Instance.GetFactureEnteteById(factureEntete.Id); #endregion #region Assert Assert.True(factureEnteteBack.ValidateBL()); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureEntete_TestTrue_CreationFactureClientNull() { try { #region Arrange var factureEntete = FactureBuilder.GenererFactureEntete(null, SingletonXpo.Instance.GetConditionPaiement()); SingletonXpo.Instance.CommitTransaction(factureEntete); #endregion #region Act var factureEnteteBack = SingletonXpo.Instance.GetFactureEnteteById(factureEntete.Id); #endregion #region Assert Assert.True(factureEnteteBack.ValidateBL()); Assert.Equal(ConstantsTPFact.ClientInvalidSystemName, factureEnteteBack.ClientNom); #endregion #region Clear DB factureEnteteBack.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestTrue_ValidateBLMontantValide(decimal montantHtva, int quantite) { try { #region Arrange var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); var factureDetail = FactureBuilder.GenererFactureDetails(factureEntete, montantHtva, quantite); #endregion #region Act bool val = factureDetail.ValidateBL(); #endregion #region Assert Assert.True(val); #endregion #region Clear DB factureDetail.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestFalse_ValidateBLSansFactureEntete() { try { #region Arrange var factureDetail = FactureBuilder.GenererFactureDetails(); #endregion #region Act bool val = factureDetail.ValidateBL(); #endregion #region Assert Assert.False(val); #endregion #region Clear DB factureDetail.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureEntete_TestTrue_ValidateBL() { try { #region Arrange var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); #endregion #region Act bool testsValue = factureEntete.ValidateBL(); #endregion #region Assert Assert.True(testsValue); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestTrue_CreationDetails() { try { #region Arrange //FactureEntete var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); //FactureDetail var factureDetail = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); //Commit SingletonXpo.Instance.CommitTransaction(factureEntete); SingletonXpo.Instance.CommitTransaction(factureDetail); #endregion #region Act var factureDetailBack = SingletonXpo.Instance.GetFactureDetailById(factureDetail.Id); #endregion #region Assert Assert.Equal(factureDetail.Id, factureDetailBack.Id); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestTrue_Creation4FactureDetailsWithMultipleOperations() { try { #region Arrange //FactureEntete var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); //FactureDetail var factureDetail1 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail2 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail3 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail4 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); //Ajout des details factureEntete.MontantHTVA = 0; decimal?totalDetails = 0; foreach (Entities.TPFact.FactureDetails detail in factureEntete.Details_Facture) { totalDetails += detail.MontantHTVA * detail.Quantité; } factureDetail3.Delete(); totalDetails -= factureDetail3.MontantHTVA * factureDetail3.Quantité; //Commit SingletonXpo.Instance.CommitTransaction(factureEntete); #endregion #region Act var factureEnteteBack = SingletonXpo.Instance.GetFactureEnteteById(factureEntete.Id); #endregion #region Assert Assert.Equal(factureEntete.Id, factureEnteteBack.Id); Assert.Equal(factureEntete.MontantHTVA, totalDetails); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestFalse_CreationFactureDetailsWithNegativeAmount() { try { #region Arrange //FactureEntete var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); //FactureDetail var factureDetail1 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); //Ajout des details factureEntete.Details_Facture.Add(factureDetail1); factureDetail1.MontantHTVA = ConstantsTPFact.FactureDetailMontantHTVANegatif; factureDetail1.Quantité = ConstantsTPFact.FactureDetailQuantite; //Commit SingletonXpo.Instance.CommitTransaction(factureEntete); #endregion #region Act var factureEnteteBack = SingletonXpo.Instance.GetFactureEnteteById(factureEntete.Id); #endregion #region Assert Assert.Equal(factureEntete.Id, factureEnteteBack.Id); Assert.False(factureDetail1.ValidateBL()); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }
public void TPFact_FactureDetails_TestTrue_Creation4FactureDetailsWithMultipleOperationsAndUpDateDetails() { try { #region Arrange //FactureEntete var factureEntete = FactureBuilder.GenererFactureEntete(ConstantsTPFact.ClientValidName, SingletonXpo.Instance.GetConditionPaiement()); //FactureDetail var factureDetail1 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail2 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail3 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); var factureDetail4 = FactureBuilder.GenererFactureDetails(factureEntete, ConstantsTPFact.FactureDetailMontantHTVA, ConstantsTPFact.FactureDetailQuantite); //Ajout des details factureEntete.MontantHTVA = 0; factureEntete.Details_Facture.Add(factureDetail1); factureEntete.Details_Facture.Add(factureDetail2); factureEntete.Details_Facture.Add(factureDetail3); factureEntete.Details_Facture.Add(factureDetail4); factureDetail1.MontantHTVA = 15.5M; factureDetail1.Quantité = 30; factureDetail2.MontantHTVA = 200; factureDetail2.Quantité = 3; factureDetail3.MontantHTVA = 60; factureDetail3.Quantité = 60; factureDetail4.MontantHTVA = 1000; factureDetail4.Quantité = 9; factureDetail3.Delete(); factureDetail2.MontantHTVA = 400; //Commit SingletonXpo.Instance.CommitTransaction(factureEntete); #endregion #region Act var factureEnteteBack = SingletonXpo.Instance.GetFactureEnteteById(factureEntete.Id); #endregion #region Assert Assert.Equal(factureEntete.Id, factureEnteteBack.Id); Assert.Equal(10665, factureEntete.MontantHTVA); #endregion #region Clear DB factureEntete.Delete(); #endregion } catch (Exception ex) { Assert.True(false, ex.ToString()); } }