private void ReadMeExample()
        {
            //Get our configuration for a pizza
            var configurationBuilder = new PizzaConfigurationBuilder();
            var configuration        = configurationBuilder.Build();

            //Set our options
            var optionsSetter = new ConfigurationItemOptionsSetter();

            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Size", "Large", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Crust", "Thick", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Toppings", "Extra Cheese", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Toppings", "Pepperoni", true);

            //Make sure the configuration is correct
            var           checker = new ConfigurationRulesChecker();
            List <string> errors;

            checker.Check(configuration, out errors);

            if (errors.Any())
            {
                return;
            }

            //Export the results to JSON
            var exporter = new ConfigurationExporter();
            var output   = exporter.ExportToJson(configuration);
        }
Exemple #2
0
        public void An_InComplete_Instance_Returns_Errors()
        {
            var configuration = PizzaConfigurationBuilder.BuildWithNoSetOptions();
            var checker       = new ConfigurationRulesChecker();

            List <string> errors;

            checker.Check(configuration, out errors);

            Assert.IsNotEmpty(errors);
        }
Exemple #3
0
        public void A_Complete_Instance_Returns_No_Errors()
        {
            var configuration = PizzaConfigurationBuilder.BuildCompleteInstance();
            var checker       = new ConfigurationRulesChecker();

            List <string> errors;

            checker.Check(configuration, out errors);

            Assert.IsEmpty(errors);
        }
Exemple #4
0
        public void Min_Selected_Options_Rule_Does_Not_Return_An_Error()
        {
            var checker    = new ConfigurationRulesChecker();
            var configItem = new ConfigurationItem();

            configItem.ConfigurationItemOptions.Add(new ConfigurationItemOption {
                Name = "Test", IsSelected = true
            });

            string error;

            checker.MinSelectedOptionsRuleCheck(configItem, new MinSelectedOptionsRule {
                Count = 1
            }, out error);

            Assert.IsEmpty(error);
        }
        private void ReadMeExample()
        {
            //Get our configuration for a pizza
            var configurationBuilder = new PizzaConfigurationBuilder();
            var configuration = configurationBuilder.Build();

            //Set our options
            var optionsSetter = new ConfigurationItemOptionsSetter();
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Size", "Large", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Crust", "Thick", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Toppings", "Extra Cheese", true);
            optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Toppings", "Pepperoni", true);

            //Make sure the configuration is correct
            var checker = new ConfigurationRulesChecker();
            List<string> errors;
            checker.Check(configuration, out errors);

            if (errors.Any())
            {
                return;
            }

            //Export the results to JSON
            var exporter = new ConfigurationExporter();
            var output = exporter.ExportToJson(configuration);
        }