public void DefaultErrorDetailPolicyShouldBeAlways() { MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver()); Assert.AreEqual(IncludeErrorDetailPolicy.Always, MyWebApi.Configuration.IncludeErrorDetailPolicy); MyWebApi.IsUsing(TestObjectFactory.GetHttpConfigurationWithRoutes()); }
public void WithErrorDetailPolicyShouldSetCorrectErrorDetailPolicy() { MyWebApi.IsUsingDefaultHttpConfiguration().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 IsUsingDefaultConfigurationShouldWorkCorrectly() { MyWebApi.IsUsingDefaultHttpConfiguration(); Assert.IsNotNull(MyWebApi.Configuration); Assert.AreEqual(0, MyWebApi.Configuration.Routes.Count); 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()); }
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()); }
public void WithCustomDependencyResolverAsConstructorFunctionShouldWorkCorrectly() { MyWebApi .IsUsingDefaultHttpConfiguration() .WithDependencyResolver(() => new CustomDependencyResolver()); var controller = MyWebApi .Controller <NoParameterlessConstructorController>() .AndProvideTheController(); Assert.IsNotNull(controller); Assert.IsNotNull(controller.Service); MyWebApi.IsUsingDefaultHttpConfiguration(); }
public void WithCustomDependencyResolverShouldWorkCorrectly() { MyWebApi .IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver()) .WithDependencyResolver(new CustomDependencyResolver()); var controller = MyWebApi .Controller <NoParameterlessConstructorController>() .AndProvideTheController(); Assert.IsNotNull(controller); Assert.IsNotNull(controller.Service); MyWebApi.IsUsingDefaultHttpConfiguration(TestObjectFactory.GetCustomInlineConstraintResolver()); }
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()); }
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(); }