Esempio n. 1
0
 public void Newlines_seperate_directives()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse(@"Load TestName
     Load TestTwo");
     AssertLoadNames(loader, "TestName", "TestTwo");
 }
Esempio n. 2
0
 public void Run_directive_calls_app_factory()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse(@"
     Load TestName
     Run TestApp
     ");
     var app = builder.ToApp();
     Assert.That(app, Is.SameAs(TestApp.Singleton));
 }
Esempio n. 3
0
        public void Leading_and_trailing_newlines_ignored()
        {
            var loader = new StubAssemblyLoader();
            var builder = new Builder(loader);
            builder.Parse(@"

            Load TestName
            Load TestTwo

            ");
            AssertLoadNames(loader, "TestName", "TestTwo");
        }
Esempio n. 4
0
 public void Run_with_an_enumerable_fnapp_argument_will_wrap_all_previous_run_calls()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse(@"
     Load TestName
     Use TestMiddleware
     Run TestApp
     Use TestMiddleware
     Run TestApp
     Run TestCascade
     ");
     var app = builder.ToApp();
     IDictionary<string, object> env = new Dictionary<string, object>();
     app(env, ex => { }, (a, b, c) => { });
     Assert.That(env.ContainsKey("TestMiddleware"), Is.False, "the use are attached to the apps, not the cascade");
     Assert.That(env["TestCascade.Count"], Is.EqualTo(2));
 }
Esempio n. 5
0
 void AssertLoadNames(StubAssemblyLoader loader, params string[] names)
 {
     Assert.That(loader.LoadNames, Has.Count.EqualTo(names.Count()));
     foreach (var name in names) {
         Assert.That(loader.LoadNames, Has.Some.EqualTo(name));
     }
 }
Esempio n. 6
0
 public void Use_with_more_text_provides_extra_argument()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse(@"
     Load TestName
     Use TestWithData Foo
     Run TestApp
     ");
     var app = builder.ToApp();
     IDictionary<string, object> env = new Dictionary<string, object>();
     app(env, ex => { }, (a, b, c) => { });
     Assert.That(env.ContainsKey("TestWithData"), Is.True);
     Assert.That(env["TestWithData.Data"], Is.EqualTo("Foo"));
 }
Esempio n. 7
0
 public void Use_directive_calls_middleware_factory()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse(@"
     Load TestName
     Use TestMiddleware
     Run TestApp
     ");
     var app = builder.ToApp();
     IDictionary<string, object> env = new Dictionary<string, object>();
     app(env, ex => { }, (a, b, c) => { });
     Assert.That(env["TestMiddleware"], Is.True);
     Assert.That(env["TestApp"], Is.True);
 }
Esempio n. 8
0
 public void Simple_format_may_be_parsed_to_load_assemblies()
 {
     var loader = new StubAssemblyLoader();
     var builder = new Builder(loader);
     builder.Parse("Load TestName");
     AssertLoadNames(loader, "TestName");
 }