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); }
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); }
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); }
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); }