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 static Configuration BuildCompleteInstance() { var configurationBuilder = new PizzaConfigurationBuilder(); var configuration = configurationBuilder.Build(); 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); return(configuration); }
public static Configuration BuildCompleteInstance() { var configurationBuilder = new PizzaConfigurationBuilder(); var configuration = configurationBuilder.Build(); 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); return configuration; }
public void An_Option_Is_UnSet() { var configuration = PizzaConfigurationBuilder.BuildCompleteInstance(); var optionsSetter = new ConfigurationItemOptionsSetter(); var size = configuration.ConfigurationItems.FirstOrDefault(i => i.Name.Equals("Size")); Assert.IsNotNull(size); var largeOption = size.ConfigurationItemOptions.FirstOrDefault( o => o.Name.Equals("Large", StringComparison.OrdinalIgnoreCase)); Assert.IsNotNull(largeOption); Assert.IsTrue(largeOption.IsSelected); optionsSetter.SetOrUnSet(configuration.ConfigurationItems, "Size", "Large", false); Assert.IsFalse(largeOption.IsSelected); }
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); }