public void SetsSingleEnumPropertyCorrectly()
 {
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof(SingleEnumHolder));
     var actual = (SingleEnumHolder)actualFunc(new Dictionary<string, string> { { "Trekker", "Uhura" } }).Handler;
     Assert.Equal(Enterprise.Uhura, actual.Trekker);
 }
 public void CreatesTypeWithParameterlessConstructorUsingDefaultContainer()
 {
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof (ParameterlessConstructorType));
     var actual = actualFunc(new Dictionary<string, string>());
     Assert.IsType<ParameterlessConstructorType>(actual.Handler);
 }
示例#3
0
        public void CreatingTypeWithNoParameterlessConstructorUsingDefaultContainerThrowsInvalidOperationException()
        {
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(NoParameterlessConstructorType));

            Assert.Throws <InvalidOperationException>(() => actualFunc(new Dictionary <string, string>()));
        }
示例#4
0
        public void CreatesTypeWithParameterlessConstructorUsingDefaultContainer()
        {
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(ParameterlessConstructorType));
            var actual     = actualFunc(new Dictionary <string, string>());

            Assert.IsType <ParameterlessConstructorType>(actual.Handler);
        }
 public void SetsGuidPropertyCorrectly()
 {
     var guid = new Guid("FA37E0B4-2DB9-4471-BC6C-229748F417CA");
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof (GuidHolder));
     var actual = (GuidHolder)actualFunc(new Dictionary<string, string>{{"Guid",guid.ToString()}}).Handler;
     Assert.Equal(guid, actual.Guid);
 }
示例#6
0
        public void SetsSingleEnumPropertyCorrectly()
        {
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(SingleEnumHolder));
            var actual     = (SingleEnumHolder)actualFunc(new Dictionary <string, string> {
                { "Trekker", "Uhura" }
            }).Handler;

            Assert.Equal(Enterprise.Uhura, actual.Trekker);
        }
 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);
 }
示例#8
0
        public void SetsGuidPropertyCorrectly()
        {
            var guid       = new Guid("FA37E0B4-2DB9-4471-BC6C-229748F417CA");
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(GuidHolder));
            var actual     = (GuidHolder)actualFunc(new Dictionary <string, string> {
                { "Guid", guid.ToString() }
            }).Handler;

            Assert.Equal(guid, actual.Guid);
        }
 public void SetsEnumerableEnumPropertyCorrectly()
 {
     var enumCollection = new[]
                              {
                                  Enterprise.Kirk,
                                  Enterprise.Spock
                              };
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableEnumHolder));
     var actual = (EnumerableEnumHolder)actualFunc(new Dictionary<string, string> { { "Trekkers", "Kirk\tSpock" } }).Handler;
     Assert.Equal((IEnumerable<Enterprise>)enumCollection, (IEnumerable<Enterprise>)actual.Trekkers);
 }
 public void SetsEnumerableStringPropertyCorrectly()
 {
     var stringCollection = new[]
                              {
                                  "hello",
                                  "world"
                              };
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableStringHolder));
     var actual = (EnumerableStringHolder)actualFunc(new Dictionary<string, string> { { "Strings", "hello\tworld" } }).Handler;
     Assert.Equal((IEnumerable<string>)stringCollection, (IEnumerable<string>)actual.Strings);
 }
 public void SetsEnumerableGuidPropertyCorrectly()
 {
     var guidCollection = new[]
                              {
                                  new Guid("FA37E0B4-2DB9-4471-BC6C-229748F417CA"),
                                  new Guid("47A210D9-7E5D-480A-9300-B2CF1443C496")
                              };
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableGuidHolder));
     var actual = (EnumerableGuidHolder)actualFunc(new Dictionary<string, string> { { "Guids", "FA37E0B4-2DB9-4471-BC6C-229748F417CA\t47A210D9-7E5D-480A-9300-B2CF1443C496" } }).Handler;
     Assert.Equal(guidCollection, actual.Guids);
 }
        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", "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);
        }
示例#14
0
        public void SetsEnumerableGuidPropertyCorrectly()
        {
            var guidCollection = new[]
            {
                new Guid("FA37E0B4-2DB9-4471-BC6C-229748F417CA"),
                new Guid("47A210D9-7E5D-480A-9300-B2CF1443C496")
            };
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableGuidHolder));
            var actual     = (EnumerableGuidHolder)actualFunc(new Dictionary <string, string> {
                { "Guids", "FA37E0B4-2DB9-4471-BC6C-229748F417CA\t47A210D9-7E5D-480A-9300-B2CF1443C496" }
            }).Handler;

            Assert.Equal(guidCollection, actual.Guids);
        }
示例#15
0
        public void SetsEnumerableEnumPropertyCorrectly()
        {
            var enumCollection = new[]
            {
                Enterprise.Kirk,
                Enterprise.Spock
            };
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableEnumHolder));
            var actual     = (EnumerableEnumHolder)actualFunc(new Dictionary <string, string> {
                { "Trekkers", "Kirk\tSpock" }
            }).Handler;

            Assert.Equal((IEnumerable <Enterprise>)enumCollection, (IEnumerable <Enterprise>)actual.Trekkers);
        }
示例#16
0
        public void SetsEnumerableStringPropertyCorrectly()
        {
            var stringCollection = new[]
            {
                "hello",
                "world"
            };
            var target     = new HandlerBuilderFactory(new Configuration());
            var actualFunc = target.BuildHandlerBuilder(typeof(EnumerableStringHolder));
            var actual     = (EnumerableStringHolder)actualFunc(new Dictionary <string, string> {
                { "Strings", "hello\tworld" }
            }).Handler;

            Assert.Equal((IEnumerable <string>)stringCollection, (IEnumerable <string>)actual.Strings);
        }
        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);
        }
示例#18
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);
        }
 public void CreatingTypeWithNoParameterlessConstructorUsingDefaultContainerThrowsInvalidOperationException()
 {
     var target = new HandlerBuilderFactory(new Configuration());
     var actualFunc = target.BuildHandlerBuilder(typeof (NoParameterlessConstructorType));
     Assert.Throws<InvalidOperationException>(() => actualFunc(new Dictionary<string, string>()));
 }