public void Run(IPrinter printer) { var loader = new DefaultLoader <ILanguage>(); // we load each group here var english = loader .Load(Groups.English); var spanish = loader .Load(Groups.Spanish); var japanese = loader .Load(Groups.Japanese); // each language is under the same interface // we can use the same properties to access each // making our code very clean // Thank you! PrintThankYou(english, printer); // ¡Gracias! PrintThankYou(spanish, printer); // ありがと PrintThankYou(japanese, printer); }
public void ShouldLoadSparkMakefiles() { var options = new Options { Makefile = Path.Combine("Files", "Sakefile.shade") }; var builder = _loader.Load(options); builder.ShouldNotBe(null); }
public void Startup_Configuration_in_assembly_namespace_will_be_discovered_by_default() { var loader = new DefaultLoader(); var configuration = loader.Load(string.Empty); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); configuration = loader.Load(null); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Startup_Configuration_Attribute_will_be_discovered_by_default() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load(string.Empty, errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); configuration = loader.Load(null, errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Run(IPrinter printer) { var loader = new DefaultLoader <ILanguage>(); var english = loader .Load(Groups.English); var spanish = loader .Load(Groups.Spanish); // writes "Hello!" even though we never put English on it printer.Print(english.Hello); // properly writes ¡Hola! printer.Print(spanish.Hello); }
public void An_extra_segment_will_cause_the_match_to_fail() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.DefaultConfigurationLoaderTests+Hello.Bar"); Assert.Null(configuration); }
public void An_extra_segment_will_cause_the_match_to_fail() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.DefaultConfigurationLoaderTests+Hello.Bar"); Assert.Null(configuration); }
private IntegratedPipelineBlueprint InitializeBlueprint() { IntegratedPipelineBlueprintStage firstStage = null; string appStartup = ConfigurationManager.AppSettings[Constants.OwinAppStartup]; var loader = new DefaultLoader(); Action <IAppBuilder> startup = loader.Load(appStartup ?? string.Empty); if (startup == null) { return(null); } var appContext = OwinBuilder.Build(builder => { EnableIntegratedPipeline(builder, stage => firstStage = stage); startup.Invoke(builder); }); if (appContext == null) { return(null); } string basePath = Utils.NormalizePath(HttpRuntime.AppDomainAppVirtualPath); return(new IntegratedPipelineBlueprint(appContext, firstStage, basePath)); }
public override IEnumerable <object[]> GetData(MethodInfo methodUnderTest, Type[] parameterTypes) { var makefiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "test-*.shade").Select(Path.GetFileName); var settings = new SakeSettings { Output = Console.Out }; var loader = new DefaultLoader(new DefaultLog(settings), settings); foreach (var makefile in makefiles) { IBuilder builder; try { builder = loader.Load(new Options { Makefile = makefile }); } catch (Exception) { builder = null; } if (builder == null) { yield return(new object[] { makefile, null }); } else { foreach (var target in builder.Targets.Values.Where(target => target.Name.StartsWith("test-"))) { yield return(new object[] { makefile, target.Name }); } } } }
public void Comma_may_be_used_if_assembly_name_doesnt_match_namespace() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("DifferentNamespace.DoesNotFollowConvention, Owin.Loader.Tests", errors); Action <IAppBuilder> alternateConfiguration = loader.Load("DifferentNamespace.DoesNotFollowConvention.AlternateConfiguration, Owin.Loader.Tests", errors); DoesNotFollowConvention.ConfigurationCalls = 0; DoesNotFollowConvention.AlternateConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); Assert.Equal(0, DoesNotFollowConvention.AlternateConfigurationCalls); alternateConfiguration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); Assert.Equal(1, DoesNotFollowConvention.AlternateConfigurationCalls); }
internal static OwinAppContext Build() { string appStartup = ConfigurationManager.AppSettings[Constants.OwinAppStartup]; var loader = new DefaultLoader(); Action <IAppBuilder> startup = loader.Load(appStartup ?? string.Empty); return(Build(startup)); }
public void Startup_inferred_given_assembly_name() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.Tests"); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void An_extra_segment_will_cause_the_match_to_fail() { var loader = new DefaultLoader(); IList <string> errors = new List <string>(); Action <IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello.Bar", errors); Assert.Null(configuration); Assert.NotEmpty(errors); }
public void Load_will_find_assembly_and_type_and_static_method() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello"); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void An_extra_segment_will_cause_the_match_to_fail() { var loader = new DefaultLoader(); IList<string> errors = new List<string>(); Action<IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello.Bar", errors); Assert.Null(configuration); Assert.NotEmpty(errors); }
public void Load_will_find_assembly_and_type_and_static_method() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello"); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void Different_OwinStartupAttribute_Definition_Works() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("AlternaTeStartupAtTribute", errors); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void Friendly_Name_Used_To_Find_Alternate_Config_Method() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("AlternateConfiguraTION", errors); Startup.AlternateConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.AlternateConfigurationCalls); }
public void Load_will_find_assembly_and_type_and_static_method() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello", errors); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void Load_will_find_assembly_and_type_and_static_method() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Hello", errors); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void Friendly_Name_Startup_Configuration_Attribute_will_be_discovered() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("AFrienDlyName", errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Comma_may_be_used_if_assembly_name_doesnt_match_namespace() { var loader = new DefaultLoader(); var configuration = loader.Load("DifferentNamespace.DoesNotFollowConvention, Owin.Loader.Tests"); DoesNotFollowConvention.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); }
public void IsntCompletelyBroken() { var loader = new DefaultLoader <ILang>(); var lang_ = loader.Load("_"); lang_.Char .Should() .Be("underscore"); var langA = loader.Load("a"); langA.Char .Should() .Be("A"); var langB = loader.Load("b"); langB.Char .Should() .Be("B"); }
public void Calling_a_class_with_multiple_configs_is_okay() { var loader = new DefaultLoader(); var foo = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs.Foo"); var bar = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs.Bar"); MultiConfigs.FooCalls = 0; MultiConfigs.BarCalls = 0; Assert.NotNull(foo); Assert.NotNull(bar); foo(new AppBuilder()); Assert.Equal(1, MultiConfigs.FooCalls); Assert.Equal(0, MultiConfigs.BarCalls); bar(new AppBuilder()); Assert.Equal(1, MultiConfigs.FooCalls); Assert.Equal(1, MultiConfigs.BarCalls); }
public void Calling_a_class_with_multiple_configs_is_okay() { var loader = new DefaultLoader(); var foo = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs.Foo"); var bar = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs.Bar"); MultiConfigs.FooCalls = 0; MultiConfigs.BarCalls = 0; Assert.NotNull(foo); Assert.NotNull(bar); foo(new AppBuilder()); Assert.Equal(1, MultiConfigs.FooCalls); Assert.Equal(0, MultiConfigs.BarCalls); bar(new AppBuilder()); Assert.Equal(1, MultiConfigs.FooCalls); Assert.Equal(1, MultiConfigs.BarCalls); }
public void Method_that_returns_app_action_may_also_be_called() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Alpha"); var builder = new AppBuilder(); configuration(builder); var app = builder.Build <AppFunc>(); _alphaCalls = 0; app(new Dictionary <string, object>()); Assert.Equal(1, _alphaCalls); }
public void Configuration_method_defaults_to_Configuration_if_only_type_name_is_provided() { IList <string> errors = new List <string>(); var loader = new DefaultLoader(); Action <IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs", errors); MultiConfigs.FooCalls = 0; MultiConfigs.BarCalls = 0; MultiConfigs.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(0, MultiConfigs.FooCalls); Assert.Equal(0, MultiConfigs.BarCalls); Assert.Equal(1, MultiConfigs.ConfigurationCalls); }
internal static Action <IAppBuilder> GetAppStartup() { string appStartup = ConfigurationManager.AppSettings[Constants.OwinAppStartup]; var loader = new DefaultLoader(new ReferencedAssembliesWrapper()); IList <string> errors = new List <string>(); Action <IAppBuilder> startup = loader.Load(appStartup ?? string.Empty, errors); if (startup == null) { throw new EntryPointNotFoundException(Resources.Exception_AppLoderFailure + Environment.NewLine + " - " + string.Join(Environment.NewLine + " - ", errors) + (IsAutomaticAppStartupEnabled ? Environment.NewLine + Resources.Exception_HowToDisableAutoAppStartup : string.Empty) + Environment.NewLine + Resources.Exception_HowToSpecifyAppStartup); } return(startup); }
public void Run(IPrinter printer) { // we assign a Loader to a variable because creating a new loader is an expensive operation. // loading a language is *also* an expensive operation, so you should seek to minimize these operations as much as possible. var loader = // use a DefaultLoader for our language new DefaultLoader <ILanguage>(); var language = loader // load the English group .Load(Groups.English); // write the greeting to the screen printer.Print(language.Greeting); }
public void Comma_may_be_used_if_assembly_name_doesnt_match_namespace() { var loader = new DefaultLoader(); var configuration = loader.Load("DifferentNamespace.DoesNotFollowConvention, Owin.Loader.Tests"); DoesNotFollowConvention.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); }
public void Different_OwinStartupAttribute_Definition_Works() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("AlternaTeStartupAtTribute", errors); _helloCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, _helloCalls); }
public void Startup_Configuration_in_assembly_namespace_will_be_discovered_by_default() { var loader = new DefaultLoader(); var configuration = loader.Load(string.Empty); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); configuration = loader.Load(null); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Method_that_returns_app_action_may_also_be_called() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests.Alpha", errors); var builder = new AppBuilder(); configuration(builder); var app = builder.Build<AppFunc>(); _alphaCalls = 0; app(new Dictionary<string, object>()); Assert.Equal(1, _alphaCalls); }
public void Comma_may_be_used_if_assembly_name_doesnt_match_namespace() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("DifferentNamespace.DoesNotFollowConvention, Owin.Loader.Tests", errors); Action<IAppBuilder> alternateConfiguration = loader.Load("DifferentNamespace.DoesNotFollowConvention.AlternateConfiguration, Owin.Loader.Tests", errors); DoesNotFollowConvention.ConfigurationCalls = 0; DoesNotFollowConvention.AlternateConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); Assert.Equal(0, DoesNotFollowConvention.AlternateConfigurationCalls); alternateConfiguration(new AppBuilder()); Assert.Equal(1, DoesNotFollowConvention.ConfigurationCalls); Assert.Equal(1, DoesNotFollowConvention.AlternateConfigurationCalls); }
public void Configuration_method_defaults_to_Configuration_if_only_type_name_is_provided() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("Owin.Loader.Tests.DefaultConfigurationLoaderTests+MultiConfigs", errors); MultiConfigs.FooCalls = 0; MultiConfigs.BarCalls = 0; MultiConfigs.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(0, MultiConfigs.FooCalls); Assert.Equal(0, MultiConfigs.BarCalls); Assert.Equal(1, MultiConfigs.ConfigurationCalls); }
public void Startup_Configuration_Attribute_will_be_discovered_by_default() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load(string.Empty, errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); configuration = loader.Load(null, errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Friendly_Name_Used_To_Find_Alternate_Config_Method() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("AlternateConfiguraTION", errors); Startup.AlternateConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.AlternateConfigurationCalls); }
public void Friendly_Name_Startup_Configuration_Attribute_will_be_discovered() { IList<string> errors = new List<string>(); var loader = new DefaultLoader(); Action<IAppBuilder> configuration = loader.Load("AFrienDlyName", errors); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }
public void Startup_inferred_given_assembly_name() { var loader = new DefaultLoader(); var configuration = loader.Load("Owin.Loader.Tests"); Startup.ConfigurationCalls = 0; configuration(new AppBuilder()); Assert.Equal(1, Startup.ConfigurationCalls); }