Exemple #1
0
        private CustomizedMaterial buildCustomizedMaterial()
        {
            Material material       = buildValidMaterial();
            Finish   selectedFinish = buildMatteFinish();
            Color    selectedColor  = buildRedColor();

            return(CustomizedMaterial.valueOf(material, selectedColor, selectedFinish));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #4
0
        public void ensureCustomizedMaterialCantBeCreatedWithNullMaterial()
        {
            Color  color  = Color.valueOf("Ola", 1, 1, 1, 1);
            Finish finish = Finish.valueOf("Adeus", 12);

            Action act = () => CustomizedMaterial.valueOf(null, color, finish);

            Assert.Throws <ArgumentException>(act);
        }
Exemple #5
0
        public void ensureCustomizedMaterialCanBeCreatedWithAFinishAndAMaterialOnly()
        {
            Color    color    = Color.valueOf("ola", 1, 1, 1, 1);
            Finish   finish   = Finish.valueOf("Ola", 12);
            Material material = new Material("#HELLO123", "designation", "ola.jpg",
                                             new List <Color>(new[] { color }),
                                             new List <Finish>(new[] { finish }));

            Assert.NotNull(CustomizedMaterial.valueOf(material, finish));
        }
Exemple #6
0
        public void ensureCustomizedMaterialCantBeCreatedWithNullFinish()
        {
            Color    color    = Color.valueOf("ola", 1, 1, 1, 1);
            Material material = new Material("#eeee213", "designation", "ola.jpg",
                                             new List <Color>(new[] { color }),
                                             new List <Finish>(new[] { Finish.valueOf("Ola", 12) }));

            Action act = () => CustomizedMaterial.valueOf(material, color, null);

            Assert.Throws <ArgumentException>(act);
        }
Exemple #7
0
        public void ensureCustomizedMaterialCantBeCreatedWithNullColor()
        {
            Finish   finish   = Finish.valueOf("Ola", 12);
            Material material = new Material("#verycoolreference", "designation", "ola.jpg",
                                             new List <Color>(new[] { Color.valueOf("Ola", 1, 1, 1, 1) }),
                                             new List <Finish>(new[] { finish }));

            Action act = () => CustomizedMaterial.valueOf(material, null, finish);

            Assert.Throws <ArgumentException>(act);
        }
        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);
        }
Exemple #9
0
        public void ensureCustomizedMaterialCantHaveAFinishThatTheMaterialItReferencesDoesNotHave()
        {
            Color    color       = Color.valueOf("ola", 1, 1, 1, 1);
            Finish   finish      = Finish.valueOf("finish", 12);
            Finish   otherFinish = Finish.valueOf("im different", 23);
            Material material    = new Material("#material", "designation", "ola.jpg",
                                                new List <Color>(new[] { color }),
                                                new List <Finish>(new[] { finish }));

            Action act = () => CustomizedMaterial.valueOf(material, color, otherFinish);

            Assert.Throws <ArgumentException>(act);
        }
Exemple #10
0
        public void ensureCustomizedMaterialWithFinishOnlyAndCustomizedMaterialWithColorAndFinishAreEqual()
        {
            Finish   finish   = Finish.valueOf("Ola", 12);
            Color    color    = Color.valueOf("aerga", 1, 1, 1, 1);
            Material material = new Material("#aergaer", "aergae", "ola.jpg",
                                             new List <Color>(new[] { color }),
                                             new List <Finish>(new[] { finish }));

            CustomizedMaterial instance = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedMaterial other    = CustomizedMaterial.valueOf(material, finish);

            Assert.True(instance.Equals(other));
        }
Exemple #11
0
        public void ensureCustomizedMaterialsWithColorOnlyAreEqual()
        {
            Color    color    = Color.valueOf("ola", 1, 1, 1, 1);
            Finish   finish   = Finish.valueOf("xa", 12);
            Material material = new Material("#dzone", "areae", "ola.jpg",
                                             new List <Color>(new[] { color }),
                                             new List <Finish>(new[] { finish }));

            CustomizedMaterial instance = CustomizedMaterial.valueOf(material, color);
            CustomizedMaterial other    = CustomizedMaterial.valueOf(material, color);

            Assert.True(instance.Equals(other));
        }
Exemple #12
0
        public void ensureCustomizedMaterialsWithFinishOnlyWithDifferentFinishesAreNotEqual()
        {
            Finish   finish      = Finish.valueOf("Ola", 12);
            Finish   otherFinish = Finish.valueOf("bananas", 12);
            Color    color       = Color.valueOf("aerg", 1, 1, 1, 1);
            Material material    = new Material("#aerga", "asdfsa", "ola.jpg",
                                                new List <Color>(new[] { color }),
                                                new List <Finish>(new[] { finish, otherFinish }));

            CustomizedMaterial instance = CustomizedMaterial.valueOf(material, finish);
            CustomizedMaterial other    = CustomizedMaterial.valueOf(material, otherFinish);

            Assert.False(instance.Equals(other));
        }
Exemple #13
0
        public void ensureCustomizedMaterialsWithDifferentFinishesAreNotEqual()
        {
            Color    color       = Color.valueOf("ola", 1, 1, 1, 1);
            Finish   finish      = Finish.valueOf("xa", 12);
            Finish   otherFinish = Finish.valueOf("ax", 12);
            Material material    = new Material("#dzone", "areae", "ola.jpg",
                                                new List <Color>(new[] { color }),
                                                new List <Finish>(new[] { finish, otherFinish }));

            CustomizedMaterial instance = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedMaterial other    = CustomizedMaterial.valueOf(material, color, otherFinish);

            Assert.False(instance.Equals(other));
        }
Exemple #14
0
        public void ensureCustomizedMaterialAndInstanceOfDifferentTypeAreNotEqual()
        {
            Finish       finish = Finish.valueOf("Acabamento polido", 12);
            Color        color  = Color.valueOf("Azul", 1, 1, 1, 1);
            List <Color> colors = new List <Color>();

            colors.Add(color);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);
            Material           material     = new Material("1234", "Material", "ola.jpg", colors, finishes);
            CustomizedMaterial custMaterial = CustomizedMaterial.valueOf(material, color, finish);

            Assert.False(custMaterial.Equals(finishes));
        }
Exemple #15
0
        public void ensureCustomizedMaterialsWithSameMaterialSameColorSameFinishAreEqual()
        {
            Color        color  = Color.valueOf("Azul", 1, 1, 1, 1);
            Finish       finish = Finish.valueOf("Acabamento polido", 12);
            List <Color> colors = new List <Color>();

            colors.Add(color);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);
            Material           material      = new Material("1234", "Material", "ola.jpg", colors, finishes);
            CustomizedMaterial custMaterial1 = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedMaterial custMaterial2 = CustomizedMaterial.valueOf(material, color, finish);

            Assert.True(custMaterial1.Equals(custMaterial2));
        }
Exemple #16
0
        public void ensureCustomizedMaterialsWithDifferentMaterialsAreNotEqual()
        {
            Color    color    = Color.valueOf("ola", 1, 1, 1, 1);
            Finish   finish   = Finish.valueOf("xau", 12);
            Material material = new Material("#imdifferent", "aerg", "ola.jpg",
                                             new List <Color>(new[] { color }),
                                             new List <Finish>(new[] { finish }));
            Material otherMaterial = new Material("#imalsodifferent", "aerge", "ola.jpg",
                                                  new List <Color>(new[] { color }),
                                                  new List <Finish>(new[] { finish }));

            CustomizedMaterial instance = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedMaterial other    = CustomizedMaterial.valueOf(otherMaterial, color, finish);

            Assert.False(instance.Equals(other));
        }
Exemple #17
0
        public void testToString()
        {
            Color        color  = Color.valueOf("Azul", 1, 1, 1, 1);
            Finish       finish = Finish.valueOf("Acabamento polido", 12);
            List <Color> colors = new List <Color>();

            colors.Add(color);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);
            Material           material      = new Material("1234", "Material", "ola.jpg", colors, finishes);
            CustomizedMaterial custMaterial1 = CustomizedMaterial.valueOf(material, color, finish);
            CustomizedMaterial custMaterial2 = CustomizedMaterial.valueOf(material, color, finish);

            Assert.Equal(custMaterial1.ToString(), custMaterial2.ToString());
        }
        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);
        }
        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));
        }
Exemple #20
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());
        }
Exemple #21
0
        public void ensureChangeFinishDoesNotChangeFinishIfNewFinishIsNull()
        {
            Color        color  = Color.valueOf("Azul", 1, 1, 1, 1);
            Finish       finish = Finish.valueOf("Acabamento polido", 12);
            List <Color> colors = new List <Color>();

            colors.Add(color);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);
            Material           material           = new Material("1234", "Material", "ola.jpg", colors, finishes);
            CustomizedMaterial customizedMaterial = CustomizedMaterial.valueOf(material, color, finish);

            Action act = () => customizedMaterial.changeFinish(null);

            Assert.Throws <ArgumentException>(act);
            Assert.Equal(customizedMaterial.finish, finish);
        }
Exemple #22
0
        public void ensureChangeFinishChangesFinish()
        {
            Color        color       = Color.valueOf("Azul", 1, 1, 1, 1);
            Finish       finish      = Finish.valueOf("Acabamento polido", 12);
            Finish       otherFinish = Finish.valueOf("Wax", 12);
            List <Color> colors      = new List <Color>();

            colors.Add(color);
            List <Finish> finishes = new List <Finish>();

            finishes.Add(finish);
            finishes.Add(otherFinish);
            Material           material           = new Material("1234", "Material", "ola.jpg", colors, finishes);
            CustomizedMaterial customizedMaterial = CustomizedMaterial.valueOf(material, color, finish);

            Assert.True(customizedMaterial.changeFinish(otherFinish));
            Assert.NotEqual(customizedMaterial.finish, finish);
        }
Exemple #23
0
        public void ensureCreationIsSucessfulWithAValidCustomizedProductCollectionAndCustomizedProduct()
        {
            //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.NotNull(new CollectionProduct(new CustomizedProductCollection("Hang in there"),
                                                 CustomizedProductBuilder.createCustomizedProduct("reference", product,
                                                                                                  CustomizedDimensions.valueOf(500.0, 500.0, 500.0))
                                                 .withMaterial(CustomizedMaterial.valueOf(material, color, finish)).build()));
        }
Exemple #24
0
        public void ensureCustomizedMaterialCantHaveAColorThatTheMaterialItReferencesDoesNotHave()
        {
            Color    color      = Color.valueOf("ola", 1, 1, 1, 1);
            Color    otherColor = Color.valueOf("adeus", 1, 1, 1, 1);
            Finish   finish     = Finish.valueOf("finish", 12);
            Material material   = new Material("#material", "designation", "ola.jpg",
                                               new List <Color>()
            {
                color
            },
                                               new List <Finish>()
            {
                finish
            });

            Action act = () => CustomizedMaterial.valueOf(material, otherColor, finish);

            Assert.Throws <ArgumentException>(act);
        }
        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>
        /// Transforms a customized product dto into a customized product via service
        /// </summary>
        /// <param name="customizedProductDTO">CustomizedProductDTO with the customized product dto being transformed</param>
        /// <returns>CustomizedProduct with the of customized products transformed from the dto</returns>
        public static CustomizedProduct transform(CustomizedProductDTO customizedProductDTO)
        {
            CustomizedProduct customizedProduct = null;

            string reference   = customizedProductDTO.reference;
            string designation = customizedProductDTO.designation;

            //Fetch the product associated to this customized product by its id
            long    productId = customizedProductDTO.productDTO.id;
            Product product   = PersistenceContext.repositories().createProductRepository().find(productId);

            //Fetch the material associated to the customized material
            long     materialId = customizedProductDTO.customizedMaterialDTO.material.id;
            Material material   = PersistenceContext.repositories().createMaterialRepository().find(materialId);

            Finish customizedFinish = customizedProductDTO.customizedMaterialDTO.finish.toEntity();
            Color  customizedColor  = customizedProductDTO.customizedMaterialDTO.color.toEntity();

            CustomizedDimensions customizedDimensions = customizedProductDTO.customizedDimensionsDTO.toEntity();
            CustomizedMaterial   customizedMaterial   = CustomizedMaterial.valueOf(material, customizedColor, customizedFinish);

            //check if the dto contains slot information

            /* if (customizedProductDTO.slotListDTO == null)
             * {
             *  customizedProduct = new CustomizedProduct(reference, designation, customizedMaterial, customizedDimensions, product);
             * }
             * else
             * {
             *  //if the dto contains slot info, then create one with slots
             *  List<Slot> slots = new SlotDTOService().transform(customizedProductDTO.slotListDTO).ToList();
             *  customizedProduct = new CustomizedProduct(reference, designation, customizedMaterial, customizedDimensions, product, slots);
             * } */

            return(customizedProduct);
        }
Exemple #30
0
        /// <summary>
        /// Creates a new instance of CustomizedMaterial.
        /// </summary>
        /// <param name="addCustomizedMaterialModelView">AddCustomizedMaterialModelView representing the CustomizedMaterial's data.</param>
        /// <returns>An instance of CustomizedMaterial.</returns>
        /// <exception cref="System.ArgumentException">Thrown when no Material could be found with the provided identifier.</exception>
        public static CustomizedMaterial create(AddCustomizedMaterialModelView addCustomizedMaterialModelView)
        {
            MaterialRepository materialRepository = PersistenceContext.repositories().createMaterialRepository();

            Material material = materialRepository.find(addCustomizedMaterialModelView.materialId);

            if (material == null)
            {
                throw new ArgumentException(string.Format(ERROR_UNABLE_TO_FIND_MATERIAL, addCustomizedMaterialModelView.materialId));
            }
            //TODO: replace usage of dto
            FinishDTO finishDTO = addCustomizedMaterialModelView.finish;
            ColorDTO  colorDTO  = addCustomizedMaterialModelView.color;

            if (finishDTO == null && colorDTO == null)
            {
                throw new ArgumentException(NULL_COLOR_AND_FINISH);
            }

            CustomizedMaterial customizedMaterial = null;

            if (finishDTO == null && colorDTO != null)
            {
                customizedMaterial = CustomizedMaterial.valueOf(material, colorDTO.toEntity());
            }
            else if (finishDTO != null && colorDTO == null)
            {
                customizedMaterial = CustomizedMaterial.valueOf(material, finishDTO.toEntity());
            }
            else
            {
                customizedMaterial = CustomizedMaterial.valueOf(material, colorDTO.toEntity(), finishDTO.toEntity());
            }

            return(customizedMaterial);
        }