static TestCasesSet()
        {
            List <TestData> testDataList = new List <TestData>();

            MoneyValue salesValue = MoneyValue.Of(1000);
            SalesData  salesData  = new SalesData(salesValue, "Standard", false);

            testDataList.Add(new TestData(salesData, Points.Of(10)));

            MoneyValue salesValueIsWithdrawn = MoneyValue.Of(1000);
            SalesData  salesDataIsWithdrawn  = new SalesData(salesValueIsWithdrawn, "Standard", true);

            testDataList.Add(new TestData(salesDataIsWithdrawn, Points.Of(0)));

            MoneyValue salesValuePremium = MoneyValue.Of(1000);
            SalesData  salesDataPremium  = new SalesData(salesValuePremium, "Premium", false);

            testDataList.Add(new TestData(salesDataPremium, Points.Of(20)));

            MoneyValue salesValueProductWithoutPrice = MoneyValue.Of(1000);
            SalesData  salesDataProductWithoutPrice  =
                new SalesData(salesValueProductWithoutPrice, "Undefined", false);

            testDataList.Add(new TestData(salesDataProductWithoutPrice, Points.Of(0)));

            TestCases = testDataList.Select(x => new TestCaseData(x.SalesData, x.ExpectedPoints));
        }
        public void SalesCalculator_Calculate_Test(
            SalesData salesData,
            Points expectedPoints)
        {
            var priceList = CreatePriceList();

            Points points = SalesCalculator.Calculate(salesData, priceList);

            Assert.That(points, Is.EqualTo(expectedPoints));
        }
        public static Points Calculate(SalesData salesData, PriceList priceList)
        {
            if (salesData.IsWithdrawn)
            {
                return(Points.Of(0));
            }

            MoneyValue moneyForOnePoint = priceList.GetValueForPointForProductCategory(salesData.ProductCategory);

            if (moneyForOnePoint != MoneyValue.Of(0))
            {
                return(Points.Of(salesData.Value / moneyForOnePoint));
            }

            return(Points.Of(0));
        }
 public TestData(SalesData salesData, Points expectedPoints)
 {
     SalesData      = salesData;
     ExpectedPoints = expectedPoints;
 }