/// <summary>
        /// Builds an instance of CustomizedProduct based on the given Product with the data in the given instance of AddCustomizedProductModelView.
        /// </summary>
        /// <param name="addCustomizedProductModelView">AddCustomizedProductModelView containing the CustomizedProduct's information.</param>
        /// <param name="product">Instance of Product.</param>
        /// <param name="parentCustomizedProduct">Parent CustomizedProduct.</param>
        /// <param name="insertedInSlot">Slot in which the CustomizedProduct will be inserted.</param>
        /// <exception cref="System.ArgumentException">
        /// Thrown when the Material referenced by the CustomizedMaterial is not found or when no CustomizedDimensions are provided.
        /// </exception>
        /// <returns>A new instance of CustomizedProduct.</returns>
        private static CustomizedProduct buildSubCustomizedProduct(AddCustomizedProductModelView addCustomizedProductModelView, Product product,
                                                                   CustomizedProduct parentCustomizedProduct, Slot insertedInSlot)
        {
            CustomizedProductBuilder customizedProductBuilder = null;

            if (addCustomizedProductModelView.customizedDimensions == null)
            {
                throw new ArgumentException(ERROR_NO_CUSTOMIZED_DIMENSIONS);
            }

            CustomizedDimensions customizedProductDimensions = CustomizedDimensionsModelViewService.fromModelView(addCustomizedProductModelView.customizedDimensions);

            if (addCustomizedProductModelView.userAuthToken == null)
            {
                customizedProductBuilder = CustomizedProductBuilder.createCustomizedProduct(product, customizedProductDimensions, parentCustomizedProduct, insertedInSlot);
            }
            else
            {
                customizedProductBuilder = CustomizedProductBuilder
                                           .createCustomizedProduct(addCustomizedProductModelView.userAuthToken, product, customizedProductDimensions, parentCustomizedProduct, insertedInSlot);
            }

            if (addCustomizedProductModelView.customizedMaterial != null)
            {
                CustomizedMaterial customizedMaterial = CreateCustomizedMaterialService.create(addCustomizedProductModelView.customizedMaterial);

                customizedProductBuilder.withMaterial(customizedMaterial);
            }

            //ignore designation since only the base customized products can set the designation

            return(customizedProductBuilder.build());
        }
Beispiel #2
0
        public void ensureNotEqualCustomizedProductCollectionsAreNotEqual()
        {
            var category = new ProductCategory("It's-a-me again");

            //Creating Dimensions
            Dimension heightDimension = new SingleValueDimension(21);
            Dimension widthDimension  = new SingleValueDimension(30);
            Dimension depthDimension  = new SingleValueDimension(17);

            Measurement        measurement  = new Measurement(heightDimension, widthDimension, depthDimension);
            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };

            //Creating a material
            string reference   = "Just referencing";
            string designation = "Doin' my thing";

            List <Color> colors = new List <Color>();
            Color        color  = Color.valueOf("Goin' to church", 1, 2, 3, 0);
            Color        color1 = Color.valueOf("Burro quando foge", 1, 2, 3, 4);

            colors.Add(color);
            colors.Add(color1);

            List <Finish> finishes = new List <Finish>();
            Finish        finish   = Finish.valueOf("Prayin'", 3);
            Finish        finish2  = Finish.valueOf("Estragado", 9);

            finishes.Add(finish);
            finishes.Add(finish2);

            Material        material  = new Material(reference, designation, "ola.jpg", colors, finishes);
            List <Material> materials = new List <Material>();

            materials.Add(material);

            IEnumerable <Material> matsList = materials;

            Product product = new Product("Kinda dead", "So tired", "riperino.gltf", category, matsList, measurements);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(21, 30, 17);

            //Customized Material
            CustomizedMaterial mat = CustomizedMaterial.valueOf(material, color1, finish2);


            CustomizedProduct cp = CustomizedProductBuilder
                                   .createCustomizedProduct("reference", product, customizedDimensions)
                                   .withMaterial(mat).build();

            cp.finalizeCustomization();
            List <CustomizedProduct> products = new List <CustomizedProduct>();

            products.Add(cp);

            Assert.NotEqual(new CustomizedProductCollection("Mario", products), new CustomizedProductCollection("Luigi", products));
        }
Beispiel #3
0
        public void ensureApplyAllRestrictionsReturnsNullIfProductDoesNotObeyRestrictions()
        {
            ProductCategory cat = new ProductCategory("All Products");

            Color        black  = Color.valueOf("Deep Black", 0, 0, 0, 0);
            Color        white  = Color.valueOf("Blinding White", 255, 255, 255, 0);
            List <Color> colors = new List <Color>()
            {
                black, white
            };

            Finish        glossy   = Finish.valueOf("Glossy", 100);
            Finish        matte    = Finish.valueOf("Matte", 0);
            List <Finish> finishes = new List <Finish>()
            {
                glossy, matte
            };

            Material material  = new Material("#001", "Really Expensive Wood", "ola.jpg", colors, finishes);
            Material material2 = new Material("#002", "Expensive Wood", "ola.jpg", colors, finishes);

            Dimension heightDimension = new SingleValueDimension(50);
            Dimension widthDimension  = new DiscreteDimensionInterval(new List <double>()
            {
                60, 65, 70, 80, 90, 105
            });
            Dimension depthDimension = new ContinuousDimensionInterval(10, 25, 5);

            Measurement measurement = new Measurement(heightDimension, widthDimension, depthDimension);

            Product product = new Product("Test", "Shelf", "shelf.glb", cat, new List <Material>()
            {
                material, material2
            }, new List <Measurement>()
            {
                measurement
            }, ProductSlotWidths.valueOf(4, 4, 4));
            Product product2 = new Product("Test", "Shelf", "shelf.glb", cat, new List <Material>()
            {
                material
            }, new List <Measurement>()
            {
                measurement
            }, ProductSlotWidths.valueOf(4, 4, 4));

            CustomizedDimensions customDimension   = CustomizedDimensions.valueOf(50, 80, 25);
            CustomizedMaterial   customMaterial    = CustomizedMaterial.valueOf(material2, white, matte);
            CustomizedProduct    customizedProduct = CustomizedProductBuilder.createCustomizedProduct("reference", product, customDimension).build();

            customizedProduct.changeCustomizedMaterial(customMaterial);

            customizedProduct.finalizeCustomization();
            RestrictableImpl instance = new RestrictableImpl();

            instance.addRestriction(new Restriction("same material", new SameMaterialAndFinishAlgorithm()));
            Assert.Null(instance.applyAllRestrictions(customizedProduct, product2));
        }
        private CustomizedProduct buildCustomizedProduct(string reference, CustomizedDimensions customizedDimensions)
        {
            Finish matte = Finish.valueOf("Matte", 30);
            Color  red   = Color.valueOf("Red", 255, 0, 0, 0);

            CustomizedMaterial customizedMaterial = CustomizedMaterial.valueOf(buildMaterial(), red, matte);

            CustomizedProduct customizedProduct = CustomizedProductBuilder.createCustomizedProduct(reference, buildProduct(), customizedDimensions)
                                                  .withMaterial(customizedMaterial).build();

            return(customizedProduct);
        }
Beispiel #5
0
        private CustomizedProduct buildUnfinishedCustomizedProductInstance()
        {
            string reference = "123";

            CustomizedMaterial customizedMaterial = buildCustomizedMaterial();

            CustomizedDimensions selectedDimensions = buildCustomizedDimensions();

            CustomizedProduct customizedProduct = CustomizedProductBuilder.createCustomizedProduct(reference, buildValidProduct(), selectedDimensions).build();

            customizedProduct.changeCustomizedMaterial(customizedMaterial);

            return(customizedProduct);
        }
        public void ensureApplyRemovesContinuousDimensions()
        {
            Color                       color        = Color.valueOf("Open the Steins Gate", 100, 100, 100, 100);
            Finish                      finish       = Finish.valueOf("der alte wurfelt nicht", 15);
            Material                    material     = new Material("#12", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory             cat          = new ProductCategory("AI");
            ContinuousDimensionInterval continuous1  = new ContinuousDimensionInterval(110.0, 150.0, 2.0);
            ContinuousDimensionInterval continuous2  = new ContinuousDimensionInterval(50.0, 80.0, 2.0);
            Measurement                 measurement1 = new Measurement(continuous1, continuous1, continuous1);
            Measurement                 measurement2 = new Measurement(continuous2, continuous2, continuous2);
            ContinuousDimensionInterval continuous3  = new ContinuousDimensionInterval(35.0, 45.0, 1.0);
            ContinuousDimensionInterval continuous4  = new ContinuousDimensionInterval(10.0, 20.0, 2.0);
            Measurement                 measurement3 = new Measurement(continuous3, continuous3, continuous3);
            Measurement                 measurement4 = new Measurement(continuous4, continuous4, continuous4);
            List <Measurement>          measurements = new List <Measurement>()
            {
                measurement1, measurement2
            };
            List <Measurement> measurements2 = new List <Measurement>()
            {
                measurement3, measurement4
            };

            Product component2 = new Product("#24", "Milky Way Corssing", "5.glb", cat, new List <Material>(new[] { material }), measurements2);
            Product component  = new Product("#5", "Solitude of the Astigmatism: Entangled Sheep", "5.glb", cat, new List <Material>(new[] { material }), measurements2, new List <Product>()
            {
                component2
            });
            Product product = new Product("#4", "Solitude of the Mournful Flow: A Stray Sheep", "4.gltf", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(110, 110, 110);
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Assert.Null(algorithm.apply(custom, component));
        }
        public void ensureApplyRestrictsSingleValueDimensions()
        {
            Finish finish = Finish.valueOf("der alte wurfelt nicht", 20);
            Color  color  = Color.valueOf("Missing Link of the Annihilator: Absolute Zero", 100, 100, 100, 100);

            Material material = new Material("#12", "K6205", "12.jpg", new List <Color>()
            {
                color
            }, new List <Finish>()
            {
                finish
            });
            ProductCategory cat          = new ProductCategory("AI");
            Measurement     measurement  = new Measurement(new SingleValueDimension(200), new SingleValueDimension(100), new SingleValueDimension(50));
            Measurement     measurement1 = new Measurement(new SingleValueDimension(100), new SingleValueDimension(200), new SingleValueDimension(50));
            Measurement     measurement2 = new Measurement(new SingleValueDimension(100), new SingleValueDimension(50), new SingleValueDimension(200));

            List <Measurement> measurements = new List <Measurement>()
            {
                measurement, measurement1, measurement2
            };
            Product component = new Product("#16", "Altair of the Point at Infinity: Vega and Altair", "16.gltf", cat, new List <Material>(new[] { material }), measurements);
            Product product   = new Product("#23", "Arclight of the Point at Infinity: Arclight of the Sky", "23.glb", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });


            CustomizedDimensions customizedProductDimensions = CustomizedDimensions.valueOf(200, 100, 50);
            CustomizedMaterial   customizedMaterial          = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    customizedProduct           = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedProductDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Product alteredProduct = algorithm.apply(customizedProduct, component);

            Assert.Single(alteredProduct.productMeasurements);
            double remainingValue = ((SingleValueDimension)alteredProduct.productMeasurements[0].measurement.width).value;

            Assert.True(remainingValue == 100);
        }
Beispiel #8
0
        private CustomizedProduct buildCustomizedProduct(string customizedProductReference)
        {
            var category = new ProductCategory("Drawers");
            //Creating Dimensions
            List <Double> values2 = new List <Double>();

            values2.Add(500.0); //Width

            DiscreteDimensionInterval d2 = new DiscreteDimensionInterval(values2);

            Measurement        measurement  = new Measurement(d2, d2, d2);
            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };

            //Creating a material
            string reference   = "1160912";
            string designation = "FR E SH A VOCA DO";

            List <Color> colors = new List <Color>();
            Color        color  = Color.valueOf("AND READ-ER-BIBLE", 1, 2, 3, 0);

            colors.Add(color);

            List <Finish> finishes = new List <Finish>();
            Finish        finish   = Finish.valueOf("Amém", 12);

            finishes.Add(finish);

            Material        material  = new Material(reference, designation, "ola.jpg", colors, finishes);
            List <Material> materials = new List <Material>();

            materials.Add(material);

            IEnumerable <Material> matsList = materials;

            Product product = new Product("#666", "Shelf", "shelf666.glb", category, matsList, measurements);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(500.0, 500.0, 500.0);

            //Customized Material
            CustomizedMaterial custMaterial1 = CustomizedMaterial.valueOf(material, color, finish);

            return(CustomizedProductBuilder.createCustomizedProduct(customizedProductReference, product, customizedDimensions).withMaterial(custMaterial1).build());
        }
Beispiel #9
0
        public void ensureApplyWorks()
        {
            Restriction               instance     = new Restriction("oh hi mark", new SameMaterialAndFinishAlgorithm());
            Material                  material     = new Material("#24", "K6205", "ola.jpg", new List <Color>(new[] { Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100) }), new List <Finish>(new[] { Finish.valueOf("der alte wurfelt nicht", 12) }));
            Material                  material1    = new Material("#22", "Amadeus", "ola.jpg", new List <Color>(new[] { Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100) }), new List <Finish>(new[] { Finish.valueOf("der alte wurfelt nicht", 12) }));
            ProductCategory           cat          = new ProductCategory("AI");
            DiscreteDimensionInterval discrete     = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 90.0, 100.0, 150.0 }));
            Measurement               measurement  = new Measurement(discrete, discrete, discrete);
            List <Measurement>        measurements = new List <Measurement>()
            {
                measurement
            };
            Product           product   = new Product("#12", "Mother Goose of Mutual Recursion: Recursive Mother Goose", "product12.glb", cat, new List <Material>(new[] { material }), measurements);
            Product           component = new Product("#13", "Mother Goose of Diffractive Recitavo: Diffraction Mother Goose", "product13.gltf", cat, new List <Material>(new[] { material1, material }), measurements);
            CustomizedProduct custom    = CustomizedProductBuilder.createCustomizedProduct("#8", product, CustomizedDimensions.valueOf(100, 100, 100)).withMaterial(CustomizedMaterial.valueOf(material, Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100), Finish.valueOf("der alte wurfelt nicht", 12))).build();

            Assert.True(instance.applyAlgorithm(custom, component).productMaterials[0].material.Equals(material));
        }
Beispiel #10
0
        public void ensureApplyRemovesUnnecessaryFinishes()
        {
            Console.WriteLine("ensureApplyRemovesUnnecessaryFinishes");
            Material                  material     = new Material("#24", "K6205", "ola.jpg", new List <Color>(new[] { Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100) }), new List <Finish>(new[] { Finish.valueOf("der alte wurfelt nicht", 12), Finish.valueOf("schrödinger's box", 13) }));
            ProductCategory           cat          = new ProductCategory("AI");
            DiscreteDimensionInterval discrete     = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 90.0, 100.0, 150.0 }));
            Measurement               measurement  = new Measurement(discrete, discrete, discrete);
            List <Measurement>        measurements = new List <Measurement>()
            {
                measurement
            };
            Product           product   = new Product("#12", "Mother Goose of Mutual Recursion: Recursive Mother Goose", "product12.glb", cat, new List <Material>(new[] { material }), measurements);
            Product           component = new Product("#13", "Mother Goose of Diffractive Recitavo: Diffraction Mother Goose", "product13.gltf", cat, new List <Material>(new[] { material }), measurements);
            CustomizedProduct custom    = CustomizedProductBuilder.createCustomizedProduct("#8", product, CustomizedDimensions.valueOf(100, 100, 100)).withMaterial(CustomizedMaterial.valueOf(material, Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100), Finish.valueOf("schrödinger's box", 13))).build();
            Algorithm         algorithm = new AlgorithmFactory().createAlgorithm(RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM);

            Assert.Equal("schrödinger's box", algorithm.apply(custom, component).productMaterials[0].material.Finishes[0].description);
        }
Beispiel #11
0
        public void ensureNullCustomizedProductCollectionIsInvalid()
        {
            //Creates measurements and a material for the product
            List <Measurement> measurements = new List <Measurement>()
            {
                new Measurement(new DiscreteDimensionInterval(new List <Double>()
                {
                    500.0
                }),
                                new DiscreteDimensionInterval(new List <Double>()
                {
                    500.0
                }), new DiscreteDimensionInterval(new List <Double>()
                {
                    500.0
                }))
            };

            //Creates colors and finishes for the product's material list and customized product's customized material
            Color        color  = Color.valueOf("Blue", 1, 2, 3, 0);
            List <Color> colors = new List <Color>()
            {
                color
            };

            Finish        finish   = Finish.valueOf("Super shiny", 90);
            List <Finish> finishes = new List <Finish>()
            {
                finish
            };

            Material material = new Material("123", "456, how original", "ola.jpg", colors, finishes);

            //Creates a product for the customized product collection's customized product
            Product product = new Product("0L4", "H4H4", "goodmeme.glb", new ProductCategory("Drawers"), new List <Material>()
            {
                material
            }, measurements, ProductSlotWidths.valueOf(1, 5, 4));

            Assert.Throws <ArgumentException>(() => new CollectionProduct(null,
                                                                          CustomizedProductBuilder.createCustomizedProduct("reference", product,
                                                                                                                           CustomizedDimensions.valueOf(500.0, 500.0, 500.0))
                                                                          .withMaterial(CustomizedMaterial.valueOf(material, color, finish)).build()));
        }
        public void ensureApplyRemovesDiscreteDimensions()
        {
            Color                     color     = Color.valueOf("Durpa", 100, 100, 100, 100);
            Finish                    finish    = Finish.valueOf("der alte wurfelt nicht", 35);
            Material                  material  = new Material("#12", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory           cat       = new ProductCategory("AI");
            DiscreteDimensionInterval discrete  = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 110.0, 150.0 }));
            DiscreteDimensionInterval discrete2 = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 150.0, 150.0 }));

            Measurement measurement  = new Measurement(new SingleValueDimension(200), discrete, new SingleValueDimension(50));
            Measurement measurement2 = new Measurement(new SingleValueDimension(200), discrete2, new SingleValueDimension(50));

            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };
            List <Measurement> measurements2 = new List <Measurement>()
            {
                measurement2
            };
            Product component = new Product("#10", "Pandora of Provable Existence: Forbidden Cubicle", "10.gltf", cat, new List <Material>(new[] { material }), measurements2);
            Product product   = new Product("#9", "Pandora of Eternal Return: Pandora's Box", "9.fbx", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(200, 110, 50);
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Assert.Null(algorithm.apply(custom, component));
        }
        public void ensureApplyRemovesValuesFromDiscreteDimensions()
        {
            Color  color  = Color.valueOf("Epigraph of the Closed Curve: Close Epigraph", 100, 100, 100, 100);
            Finish finish = Finish.valueOf("der alte wurfelt nicht", 20);

            Material                  material    = new Material("#24", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory           cat         = new ProductCategory("AI");
            DiscreteDimensionInterval discrete    = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 90.0, 100.0, 150.0 }));
            Measurement               measurement = new Measurement(new SingleValueDimension(200), discrete, new SingleValueDimension(50));

            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };

            Product component = new Product("#13", "Mother Goose of Diffractive Recitavo: Diffraction Mother Goose", "13.glb", cat, new List <Material>(new[] { material }), measurements);
            Product product   = new Product("#12", "Mother Goose of Mutual Recursion: Recursive Mother Goose ", "12.fbx", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(200, 100, 50);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Product alteredProduct = algorithm.apply(custom, component);
            DiscreteDimensionInterval discreteDimension = (DiscreteDimensionInterval)alteredProduct.productMeasurements[0].measurement.width;
            DiscreteDimensionInterval expected          = new DiscreteDimensionInterval(new List <double>(new[] { 90.0, 100.0 }));

            Assert.True(discreteDimension.Equals(expected));
        }
        public void ensureApplyChangesContinuousDimensionsLimits()
        {
            Color                       color        = Color.valueOf("Open the Missing Link", 100, 100, 100, 100);
            Finish                      finish       = Finish.valueOf("der alte wurfelt nicht", 20);
            Material                    material     = new Material("#12", "K6205", "12.png", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory             cat          = new ProductCategory("AI");
            ContinuousDimensionInterval continuous   = new ContinuousDimensionInterval(50.0, 150.0, 20.0);
            Measurement                 measurement  = new Measurement(new SingleValueDimension(200), continuous, new SingleValueDimension(50));
            List <Measurement>          measurements = new List <Measurement>()
            {
                measurement
            };

            Product component = new Product("#19", "Altair of the Cyclic Coordinate: Time-leap Machine", "19.glb", cat, new List <Material>(new[] { material }), measurements);

            Product product = new Product("#18", "Altair of Translational Symmetry: Translational Symmetry", "18.glb", cat, new List <Material>(new[] { material }), measurements,
                                          new List <Product>()
            {
                component
            });

            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(200, 100, 50);
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Product alteredProduct = algorithm.apply(custom, component);

            Assert.True(alteredProduct.productMeasurements[0].measurement.width.getMinValue() == 90);
            Assert.True(alteredProduct.productMeasurements[0].measurement.width.getMaxValue() == 100);
            Assert.True(((ContinuousDimensionInterval)alteredProduct.productMeasurements[0].measurement.width).increment == 10);
        }
        public void ensureApplyFailsIfAlgorithmNotReady()
        {
            Color                       color        = Color.valueOf("Open the Steins Gate", 100, 100, 100, 100);
            Finish                      finish       = Finish.valueOf("der alte wurfelt nicht", 15);
            Material                    material     = new Material("#12", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory             cat          = new ProductCategory("AI");
            ContinuousDimensionInterval continuous1  = new ContinuousDimensionInterval(110.0, 150.0, 2.0);
            ContinuousDimensionInterval continuous2  = new ContinuousDimensionInterval(50.0, 80.0, 2.0);
            Measurement                 measurement1 = new Measurement(continuous1, continuous1, continuous1);
            Measurement                 measurement2 = new Measurement(continuous2, continuous2, continuous2);
            ContinuousDimensionInterval continuous3  = new ContinuousDimensionInterval(35.0, 45.0, 1.0);
            ContinuousDimensionInterval continuous4  = new ContinuousDimensionInterval(10.0, 20.0, 2.0);
            Measurement                 measurement3 = new Measurement(continuous3, continuous3, continuous3);
            Measurement                 measurement4 = new Measurement(continuous4, continuous4, continuous4);
            List <Measurement>          measurements = new List <Measurement>()
            {
                measurement1, measurement2
            };
            List <Measurement> measurements2 = new List <Measurement>()
            {
                measurement3, measurement4
            };

            Product component = new Product("#5", "Solitude of the Astigmatism: Entangled Sheep", "5.glb", cat, new List <Material>(new[] { material }), measurements2);
            Product product   = new Product("#4", "Solitude of the Mournful Flow: A Stray Sheep", "4.gltf", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(110, 110, 110);
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Action action = () => algorithm.apply(custom, component);

            Assert.Throws <ArgumentNullException>(action);
        }
        /// <summary>
        /// Builds an instance of CustomizedProduct based on the given Product with the data in the given instance of AddCustomizedProductModelView.
        /// </summary>
        /// <param name="addCustomizedProductModelView">AddCustomizedProductModelView containing the CustomizedProduct's information.</param>
        /// <param name="product">Instance of Product.</param>
        /// <returns>Built instance of CustomizedProduct.</returns>
        /// <exception cref="System.ArgumentException">
        /// Thrown when the Material referenced by the CustomizedMaterial is not found or when no CustomizedDimensions are provided.
        /// </exception>
        /// <returns>A new instance of CustomizedProduct.</returns>
        private static CustomizedProduct buildCustomizedProduct(AddCustomizedProductModelView addCustomizedProductModelView, Product product)
        {
            CustomizedProductBuilder customizedProductBuilder = null;

            if (addCustomizedProductModelView.customizedDimensions == null)
            {
                throw new ArgumentException(ERROR_NO_CUSTOMIZED_DIMENSIONS);
            }

            CustomizedDimensions customizedProductDimensions = CustomizedDimensionsModelViewService.fromModelView(addCustomizedProductModelView.customizedDimensions);

            if (addCustomizedProductModelView.userAuthToken == null)
            {
                customizedProductBuilder = CustomizedProductBuilder.createCustomizedProduct(addCustomizedProductModelView.reference, product, customizedProductDimensions);
            }
            else
            {
                customizedProductBuilder = CustomizedProductBuilder
                                           .createCustomizedProduct(addCustomizedProductModelView.userAuthToken, addCustomizedProductModelView.reference, product, customizedProductDimensions);
            }

            //build customized product with optional properties if they're defined
            if (addCustomizedProductModelView.customizedMaterial != null)
            {
                CustomizedMaterial customizedMaterial = CreateCustomizedMaterialService.create(addCustomizedProductModelView.customizedMaterial);

                customizedProductBuilder.withMaterial(customizedMaterial);
            }

            if (addCustomizedProductModelView.designation != null)
            {
                customizedProductBuilder.withDesignation(addCustomizedProductModelView.designation);
            }

            return(customizedProductBuilder.build());
        }
        private CustomizedProduct buildCustomizedProduct()
        {
            Finish finish = Finish.valueOf("Glossy", 90);
            Color  color  = Color.valueOf("Deep Purple", 153, 50, 204, 0);

            Material material = new Material("materialid", "Metal", "ola.jpg", new List <Color>()
            {
                color
            }, new List <Finish>()
            {
                finish
            });

            ProductCategory productCategory = new ProductCategory("Bands");

            Dimension heightDimension = new SingleValueDimension(21.0);
            Dimension depthDimension  = new SingleValueDimension(15.6);
            Dimension widthDimension  = new SingleValueDimension(19);

            Measurement measurement = new Measurement(heightDimension, widthDimension, depthDimension);

            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };

            Product product = new Product("productid", "Awesome shelf", "awesomeshelfyo.glb", productCategory, new List <Material>()
            {
                material
            }, measurements);

            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(21.0, 19, 15.6);

            return(CustomizedProductBuilder.createCustomizedProduct("reference", product, customizedDimensions).withMaterial(customizedMaterial).build());
        }
        public void ensureApplyCondensesDiscreteDimensions()
        {
            Color                     color        = Color.valueOf("Silver", 100, 100, 100, 100);
            Finish                    finish       = Finish.valueOf("der alte wurfelt nicht", 20);
            Material                  material     = new Material("#12", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));
            ProductCategory           cat          = new ProductCategory("AI");
            DiscreteDimensionInterval discrete     = new DiscreteDimensionInterval(new List <double>(new[] { 50.0, 100.0, 150.0 }));
            Measurement               measurement  = new Measurement(new SingleValueDimension(200), discrete, new SingleValueDimension(50));
            List <Measurement>        measurements = new List <Measurement>()
            {
                measurement
            };

            Product component = new Product("#21", "Rinascimento of Image Formation: Return of Phoenix", "21.glb", cat, new List <Material>(new[] { material }), measurements);
            Product product   = new Product("#20", "Rinascimento of the Unwavering Promise: Promised Rinascimento", "20.gltf", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(200, 100, 50);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("1235", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Product alteredProduct = algorithm.apply(custom, component);

            Assert.True(alteredProduct.productMeasurements[0].measurement.width.GetType() == typeof(SingleValueDimension));
            Assert.True(((SingleValueDimension)alteredProduct.productMeasurements[0].measurement.width).value == 100);
        }
        public void ensureApplyCondensesContinuousDimensions()
        {
            Color    color    = Color.valueOf("Open the Steins Gate", 100, 100, 100, 100);
            Finish   finish   = Finish.valueOf("der alte wurfelt nicht", 45);
            Material material = new Material("#12", "K6205", "12.jpg", new List <Color>(new[] { color }), new List <Finish>(new[] { finish }));

            ProductCategory             cat        = new ProductCategory("AI");
            ContinuousDimensionInterval continuous = new ContinuousDimensionInterval(100.0, 150.0, 2.0);
            Measurement        measurement         = new Measurement(new SingleValueDimension(200), continuous, new SingleValueDimension(50));
            List <Measurement> measurements        = new List <Measurement>()
            {
                measurement
            };
            Product component = new Product("#5", "Solitude of the Astigmatism: Entangled Sheep", "5.gltf", cat, new List <Material>(new[] { material }), measurements);
            Product product   = new Product("#4", "Solitude of the Mournful Flow: A Stray Sheep", "4.fbx", cat, new List <Material>(new[] { material }), measurements, new List <Product>()
            {
                component
            });

            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(200, 100, 50);
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedProduct    custom = CustomizedProductBuilder.createCustomizedProduct("12345", product, customizedDimensions).withMaterial(customizedMaterial).build();

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.9");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            Product alteredProduct = algorithm.apply(custom, component);

            Assert.True(alteredProduct.productMeasurements[0].measurement.width.GetType() == typeof(SingleValueDimension));
            Assert.True(((SingleValueDimension)alteredProduct.productMeasurements[0].measurement.width).value == 100);
        }
Beispiel #20
0
        public void ensureApplyAllRestrictionsReturnsRestrictedProduct()
        {
            ProductCategory cat = new ProductCategory("All Products");

            Color        black  = Color.valueOf("Deep Black", 0, 0, 0, 0);
            Color        white  = Color.valueOf("Blinding White", 255, 255, 255, 0);
            List <Color> colors = new List <Color>()
            {
                black, white
            };

            Finish        glossy   = Finish.valueOf("Glossy", 100);
            Finish        matte    = Finish.valueOf("Matte", 0);
            List <Finish> finishes = new List <Finish>()
            {
                glossy, matte
            };

            Material material  = new Material("#001", "Really Expensive Wood", "ola.jpg", colors, finishes);
            Material material2 = new Material("#002", "Expensive Wood", "ola.jpg", colors, finishes);

            Dimension heightDimension = new SingleValueDimension(50);
            Dimension widthDimension  = new DiscreteDimensionInterval(new List <double>()
            {
                60, 65, 70, 80, 90, 105
            });
            Dimension depthDimension = new ContinuousDimensionInterval(10, 25, 5);

            Measurement measurement = new Measurement(heightDimension, widthDimension, depthDimension);

            Product product = new Product("Test", "Shelf", "shelf.glb", cat, new List <Material>()
            {
                material, material2
            }, new List <Measurement>()
            {
                measurement
            }, ProductSlotWidths.valueOf(4, 4, 4));
            Product product2 = new Product("Test", "Shelf", "shelf.glb", cat, new List <Material>()
            {
                material, material2
            }, new List <Measurement>()
            {
                measurement
            }, ProductSlotWidths.valueOf(4, 4, 4));

            CustomizedDimensions customDimension   = CustomizedDimensions.valueOf(50, 80, 25);
            CustomizedMaterial   customMaterial    = CustomizedMaterial.valueOf(material, white, matte);
            CustomizedProduct    customizedProduct = CustomizedProductBuilder.createCustomizedProduct("reference", product, customDimension).build();

            customizedProduct.changeCustomizedMaterial(customMaterial);

            customizedProduct.finalizeCustomization();
            RestrictableImpl instance = new RestrictableImpl();

            instance.addRestriction(new Restriction("same material", new SameMaterialAndFinishAlgorithm()));

            WidthPercentageAlgorithm algorithm = new WidthPercentageAlgorithm();
            Input minInput = Input.valueOf("Minimum Percentage", "From 0 to 1");
            Input maxInput = Input.valueOf("Maximum Percentage", "From 0 to 1");
            Dictionary <Input, string> inputs = new Dictionary <Input, string>();

            inputs.Add(minInput, "0.8");
            inputs.Add(maxInput, "1.0");
            algorithm.setInputValues(inputs);
            instance.addRestriction(new Restriction("width percentage", algorithm));

            Product returned = instance.applyAllRestrictions(customizedProduct, product2);

            Assert.True(returned.productMaterials.Count == 1);
            Assert.True(returned.productMaterials[0].material.Equals(material));
            Assert.True(returned.productMeasurements[0].measurement.width.getMinValue() == 65);
            Assert.True(returned.productMeasurements[0].measurement.width.getMaxValue() == 80);
        }
Beispiel #21
0
        public void ensureObjectIsNotCreatedForNullCatalogueCollection()
        {
            Color        color  = Color.valueOf("Somebody", 1, 2, 3, 4);
            List <Color> colors = new List <Color>();

            colors.Add(color);

            Finish        finish   = Finish.valueOf("once", 1);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);

            List <Double> values = new List <Double>();

            values.Add(500.0);

            Material        material     = new Material("told", "me", "ola.jpg", colors, finishes);
            List <Material> materialList = new List <Material>();

            materialList.Add(material);

            ProductCategory productCategory = new ProductCategory("the");

            Dimension heightDimension = new SingleValueDimension(21);
            Dimension widthDimension  = new SingleValueDimension(30);
            Dimension depthDimension  = new SingleValueDimension(17);

            Measurement        measurement  = new Measurement(heightDimension, widthDimension, depthDimension);
            List <Measurement> measurements = new List <Measurement>()
            {
                measurement
            };

            IEnumerable <Material> materialEnumerable = materialList;

            Product product = new Product("world", "is", "world.glb", productCategory, materialEnumerable,
                                          measurements);

            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedDimensions customizedDimensions = CustomizedDimensions.valueOf(21, 30, 17);
            CustomizedProduct    customizedProduct    = CustomizedProductBuilder
                                                        .createCustomizedProduct("reference", product, customizedDimensions)
                                                        .withMaterial(customizedMaterial).build();

            customizedProduct.finalizeCustomization();

            List <CustomizedProduct> customizedProductList = new List <CustomizedProduct>();

            customizedProductList.Add(customizedProduct);

            CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("me",
                                                                                                      customizedProductList);
            List <CustomizedProductCollection> collectionList = new List <CustomizedProductCollection>();

            collectionList.Add(customizedProductCollection);

            CatalogueCollection catalogueCollection = new CatalogueCollection(customizedProductCollection,
                                                                              customizedProductList);
            List <CatalogueCollection> catalogueCollectionList = new List <CatalogueCollection>();

            catalogueCollectionList.Add(catalogueCollection);

            CommercialCatalogue commercialCatalogue = new CommercialCatalogue("I", "ain't", catalogueCollectionList);

            Assert.Throws <ArgumentException>(() => new CommercialCatalogueCatalogueCollection(commercialCatalogue,
                                                                                               null));
        }