public double CalculPoints(double price, EtatDuLivre etatDuLivre) { double nbrePoints = 0.0; switch (etatDuLivre) { case EtatDuLivre.COMMENEUF: nbrePoints = price * (int)EtatDuLivre.COMMENEUF * 0.01; break; case EtatDuLivre.BONETAT: nbrePoints = price * (int)EtatDuLivre.BONETAT * 0.01; break; case EtatDuLivre.ETATMOYEN: nbrePoints = price * (int)EtatDuLivre.ETATMOYEN * 0.01; break; case EtatDuLivre.USE: nbrePoints = price * (int)EtatDuLivre.USE * 0.01; break; } return(Math.Round(nbrePoints * 10) / 10); }
public double CalculPoints(double price, EtatDuLivre etatDuLivre, bool isExchange) { double nbrePoints = 0.0; switch (etatDuLivre) { case EtatDuLivre.COMMENEUF: if (isExchange == false) { nbrePoints = price * (int)EtatDuLivre.COMMENEUF * 0.01 * 0.25; } else { nbrePoints = price * (int)EtatDuLivre.COMMENEUF * 0.01 * 0.75; } break; case EtatDuLivre.BONETAT: if (isExchange == false) { nbrePoints = price * (int)EtatDuLivre.BONETAT * 0.01 * 0.25; } else { nbrePoints = price * (int)EtatDuLivre.BONETAT * 0.01 * 0.75; } break; case EtatDuLivre.ETATMOYEN: if (isExchange == false) { nbrePoints = price * (int)EtatDuLivre.ETATMOYEN * 0.01 * 0.25; } else { nbrePoints = price * (int)EtatDuLivre.ETATMOYEN * 0.01 * 0.75; } break; case EtatDuLivre.USE: if (isExchange == false) { nbrePoints = price * (int)EtatDuLivre.USE * 0.01 * 0.25; } else { nbrePoints = price * (int)EtatDuLivre.USE * 0.01 * 0.75; } break; } return(Math.Round(nbrePoints * 10) / 10); }
public void GetPointsByPriceAndBookStateExchangeFalse_DoesReturnNbrPoints() { //Arrange double price = 20; EtatDuLivre bonEtat = EtatDuLivre.BONETAT; double nbrPoints = price * (int)bonEtat * 0.01; bool exchange = false; //Act double nbrPointsByService = service.GetPoints(price, bonEtat, exchange); //Assert Assert.AreEqual(nbrPoints, nbrPointsByService); }
public double GetPoints(double price, EtatDuLivre etatDuLivre) { return(CalculPoints(price, etatDuLivre)); }
/// <summary> /// 1 point = 1euro /// NombreDePoint = PrixNeuf * EtatLivre(%)*isExchange /// Obtient 25% des points totaux avant échange /// </summary> /// <param name="price"></param> /// <param name="etatDuLivre"></param> /// <param name="isExchange">isExchange=true si l'echange est effectué</param> /// <returns>Nombre de points</returns> public double GetPoints(double price, EtatDuLivre etatDuLivre, bool isExchange) { return(CalculPoints(price, etatDuLivre, isExchange)); }