Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public double GetPoints(double price, EtatDuLivre etatDuLivre)
 {
     return(CalculPoints(price, etatDuLivre));
 }
Esempio n. 5
0
 /// <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));
 }