コード例 #1
0
        public void Test_that_price_is_calculated_correctly()
        {
            // Arrange
            var priceExpected = 153.6M;
            var equipments    = new List <Equipment> {
                new Equipment {
                    PriceEuro = 10
                },
                new Equipment {
                    PriceEuro = 15
                }
            };
            var rims = new Rims {
                PriceEuro = 12
            };
            var varnish = new Varnish {
                PriceEuro = 16.6M
            };

            // Act
            var priceActual = _service.CalculatePrice(Currency.Euro, equipments, rims, varnish, 20);

            // Assert
            Assert.AreEqual(priceExpected, priceActual);
        }
コード例 #2
0
 public VehicleProperties(int wheels, int passengers, Rims rims, TruckTowingCapacity towingCapacity)
 {
     Wheels         = wheels;
     Passengers     = passengers;
     Rims           = rims;
     TowingCapacity = towingCapacity;
 }
コード例 #3
0
 public ConfigurationOverviewPageViewModel(CarConfiguratorEntityContext context)
     : base(context, onlySelectedAccessories: true, onlySelectedEngineSettings: true, onlySelectedPaints: true, onlySelectedRims: true)
 {
     Configuration = new ConfigurationViewModel
     {
         Accessories    = Accessories,
         EngineSettings = EngineSettings.FirstOrDefault(),
         Paint          = Paints.FirstOrDefault(),
         Rims           = Rims.FirstOrDefault()
     };
     Configuration.InitPrice();
 }
コード例 #4
0
        static void Main(string[] args)
        {
            VisionExpress  visionexpress2  = new VisionExpress();
            GlassesBuilder glassesbuilder2 = new MultifocalBuilder();

            visionexpress2.ConstructGlasses(glassesbuilder2);
            glassesbuilder2.Glasses.Display();
            Console.WriteLine(); //pusty wiersz
            GlassProduct testglass = new GlassProduct();
            var          testuv    = new Filters(FiltersEnum.UV);

            testglass.AddElement(testuv);
            var testDefect = new DefectValue(10, -10);

            testglass.AddElement(testDefect);
            var testrims = new Rims(RimTypesEnum.Gucci);

            glassesbuilder2.Glasses.Rims      = testrims.Name;
            glassesbuilder2.Glasses.RimsPrice = testrims.Price;
            glassesbuilder2.Glasses.Price    += testuv.Price;
            glassesbuilder2.Glasses.Price    += testDefect.Price;

            //dupa.ShowList();
            testglass.AddToGlasses(glassesbuilder2.Glasses);
            glassesbuilder2.Glasses.Display();
            string path = @"Test.txt";

            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine("Orders:");
                    sw.WriteLine("-------------");
                }
            }
            using (StreamWriter sw = File.AppendText(path))
            {
                sw.WriteLine("typ:" + glassesbuilder2.Glasses._type);
                sw.WriteLine("lenses:" + glassesbuilder2.Glasses.Lenses);
                sw.WriteLine("lenses price:" + glassesbuilder2.Glasses.LensesPrice);
                sw.WriteLine("Rims:" + glassesbuilder2.Glasses.Rims);
                sw.WriteLine("Rims price:" + glassesbuilder2.Glasses.RimsPrice);
                foreach (IComposite el in glassesbuilder2.Glasses.AdditionList)
                {
                    sw.WriteLine(el.Name + " " + el.Price);
                }
                sw.WriteLine("Total price:" + (glassesbuilder2.Glasses.LensesPrice + glassesbuilder2.Glasses.RimsPrice + glassesbuilder2.Glasses.Price));
                sw.WriteLine("-------------");
            }
        }
コード例 #5
0
        void SaveRimsBtnClick(object sender, RoutedEventArgs e)
        {
            SaveRims.IsEnabled = false;
            var selectedRims = RimsComboBox.Text;

            if (!string.IsNullOrEmpty(selectedRims))
            {
                RimsComboBox.IsEnabled = false;
                switch (selectedRims)
                {
                case "Gucci rims":
                    var gucciRims = new Rims(RimTypesEnum.Gucci);
                    glasses.Rims      = gucciRims.Name;
                    glasses.RimsPrice = gucciRims.Price;
                    glasses.Price    += gucciRims.Price;
                    break;

                case "Armani rims":
                    var armaniRims = new Rims(RimTypesEnum.Armani);
                    glasses.Rims      = armaniRims.Name;
                    glasses.RimsPrice = armaniRims.Price;
                    glasses.Price    += armaniRims.Price;
                    break;

                case "Dior rims":
                    var diorRims = new Rims(RimTypesEnum.Dior);
                    glasses.Rims      = diorRims.Name;
                    glasses.RimsPrice = diorRims.Price;
                    glasses.Price    += diorRims.Price;
                    break;
                }
                if (selectedRims != "Standard")
                {
                    glasses.Price -= 100;
                }
            }
            RefreshCurrentOrderList();
        }
コード例 #6
0
        public decimal CalculatePrice(Currency currency, IEnumerable <Equipment> equipments = null, Rims rims = null, Varnish varnish = null, int?enginePower = null)
        {
            var equipmentPrice    = equipments?.Sum(_ => currency == Currency.Euro ? _.PriceEuro : _.PricePound) ?? decimal.Zero;
            var rimsesPrice       = (currency == Currency.Euro ? rims?.PriceEuro : rims?.PricePound) ?? decimal.Zero;
            var varnishesPrice    = (currency == Currency.Euro ? varnish?.PriceEuro : varnish?.PricePound) ?? decimal.Zero;
            var engingePowerPrice = (enginePower ?? 0) * (currency == Currency.Euro ? 5 : 4);

            return(equipmentPrice + rimsesPrice + varnishesPrice + engingePowerPrice);
        }