public void CreatesInstanceOfType()
 {
     var startup = new TestStartup();
     startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
     var target = new HandlerBuilderFactory(SimpleWeb.Configuration);
     var actualFunc = target.BuildHandlerBuilder(typeof(TestHandler));
     var actual = (TestHandler)actualFunc(new Dictionary<string, string[]> { { "TestProperty", new[] {"Foo"} } }).Handler;
     Assert.Equal(Status.OK, actual.Get());
     Assert.Equal("Foo", actual.TestProperty);
 }
Example #2
0
        public void CreatesInstanceOfType()
        {
            var startup = new TestStartup();

            startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
            var target     = new HandlerBuilderFactory(SimpleWeb.Configuration);
            var actualFunc = target.BuildHandlerBuilder(typeof(TestHandler));
            var actual     = (TestHandler)actualFunc(new Dictionary <string, string[]> {
                { "TestProperty", new[] { "Foo" } }
            }).Handler;

            Assert.Equal(Status.OK, actual.Get());
            Assert.Equal("Foo", actual.TestProperty);
        }
        public void DisposesInstances()
        {
            var startup = new TestStartup();
            startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
            var target = new HandlerBuilderFactory(SimpleWeb.Configuration);
            var actualFunc = target.BuildHandlerBuilder(typeof(TestHandler));

            TestHandler handler;
            using (var scopedHandler = actualFunc(new Dictionary<string, string[]>()))
            {
                handler = (TestHandler)scopedHandler.Handler;
                Assert.Equal(false, handler.IsDisposed);
            }
            Assert.Equal(true, handler.IsDisposed);
        }
Example #4
0
        public void DisposesInstances()
        {
            var startup = new TestStartup();

            startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
            var target     = new HandlerBuilderFactory(SimpleWeb.Configuration);
            var actualFunc = target.BuildHandlerBuilder(typeof(TestHandler));

            TestHandler handler;

            using (var scopedHandler = actualFunc(new Dictionary <string, string[]>()))
            {
                handler = (TestHandler)scopedHandler.Handler;
                Assert.Equal(false, handler.IsDisposed);
            }
            Assert.Equal(true, handler.IsDisposed);
        }
Example #5
0
        public void CreatesInstanceOfGenericType()
        {
            var startup = new TestStartup();

            startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);

            var target = new HandlerBuilderFactory(SimpleWeb.Configuration);

            var actualFunc = target.BuildHandlerBuilder(typeof(GenericTestHandler));

            var actual = (GenericTestHandler)actualFunc(
                new Dictionary <string, string>
            {
                { "TestProperty", null }
            }).Handler;

            var status = actual.Patch(new GenericArgument()
            {
                Name = "Foo"
            });

            Assert.Equal(Status.Created, status);
            Assert.Equal("Foo", actual.TestProperty.Name);
        }