Exemple #1
0
        public void DefaultErrorDetailPolicyShouldBeAlways()
        {
            MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver());

            Assert.AreEqual(IncludeErrorDetailPolicy.Always, MyWebApi.Configuration.IncludeErrorDetailPolicy);

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
Exemple #2
0
        public void WithErrorDetailPolicyShouldSetCorrectErrorDetailPolicy()
        {
            MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver())
            .WithErrorDetailPolicy(IncludeErrorDetailPolicy.LocalOnly);

            Assert.AreEqual(IncludeErrorDetailPolicy.LocalOnly, MyWebApi.Configuration.IncludeErrorDetailPolicy);

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
        public void IsUsingDefaultConfigurationShouldWorkCorrectly()
        {
            MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver());

            Assert.IsNotNull(MyWebApi.Configuration);
            Assert.IsTrue(MyWebApi.Configuration.Routes.ContainsKey("API Default"));

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
        public void WhenWithInlineConstraintResolverCalledShouldSetNewHttpConfigurationInstance()
        {
            var oldHttpConfiguration = MyWebApi.Configuration;

            MyWebApi
            .IsUsingDefaultHttpConfiguration()
            .WithInlineConstraintResolver(TestObjectFactory.GetCustomInlineConstraintResolver());

            Assert.AreNotSame(MyWebApi.Configuration, oldHttpConfiguration);

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
Exemple #5
0
        public void LinkGenerationShouldWorkCorrectlyWithDefaultConfiguration()
        {
            MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver());

            MyWebApi
            .Controller <WebApiController>()
            .Calling(c => c.WithGeneratedLink(1))
            .ShouldReturn()
            .Created()
            .AtLocation("http://localhost/api/test?id=1");

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
Exemple #6
0
        public void WithCustomDependencyResolverAsConstructorFunctionShouldWorkCorrectly()
        {
            MyWebApi
            .IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver())
            .WithDependencyResolver(() => new CustomDependencyResolver());

            var controller = MyWebApi
                             .Controller <NoParameterlessConstructorController>()
                             .AndProvideTheController();

            Assert.IsNotNull(controller);
            Assert.IsNotNull(controller.Service);

            MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver());
        }
Exemple #7
0
        public void LinkGenerationShouldWorkCorrectlyWithCustomBaseAddress()
        {
            MyWebApi
            .IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver())
            .WithBaseAddress("http://mytestedasp.net");

            MyWebApi
            .Controller <WebApiController>()
            .Calling(c => c.WithGeneratedLink(1))
            .ShouldReturn()
            .Created()
            .AtLocation("http://mytestedasp.net/api/test?id=1");

            RemoteServer.DisposeGlobal();
            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());
        }
Exemple #8
0
        public void WithBaseAddressShouldChangedDefaultAddress()
        {
            Assert.IsFalse(RemoteServer.GlobalIsConfigured);
            Assert.AreEqual(MyWebApi.DefaultHost, MyWebApi.BaseAddress.OriginalString);

            string address = "http://mytestedasp.net";

            MyWebApi
            .IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver())
            .WithBaseAddress(address);

            Assert.AreEqual(address, MyWebApi.BaseAddress.OriginalString);
            Assert.IsTrue(RemoteServer.GlobalIsConfigured);

            MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes());

            Assert.AreEqual(MyWebApi.DefaultHost, MyWebApi.BaseAddress.OriginalString);

            RemoteServer.DisposeGlobal();
        }