public void WhenCreatedThenAspNetCompatibilityRequirementsAttributeIsAdded() { var config = new HttpHostConfiguration(); var host = new HttpConfigurableServiceHost(new TestService(), config, new Uri(DummyUri)); Assert.IsTrue(host.Description.Behaviors.Contains(typeof(AspNetCompatibilityRequirementsAttribute))); }
public void WhenCreatedWithAnInstanceThenServiceTypeIsSet() { var config = new HttpHostConfiguration(); var host = new HttpConfigurableServiceHost(new TestService(), config, new Uri(DummyUri)); Assert.AreEqual(typeof(TestService), host.serviceType); }
public void WhenCreatedWithATypeThenConfigurationIsSet() { var config = new HttpHostConfiguration(); var host = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri)); Assert.AreEqual(config, host.configuration); }
public void WhenCreatedThenHttpEndpointIsAddedToTheService() { var config = new HttpHostConfiguration(); var host = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri)); var httpEndpoint = (HttpEndpoint)host.Description.Endpoints.Find(typeof(TestService)); Assert.IsNotNull(httpEndpoint); }
public void TearDown() { if (host != null) { host.Close(); host = null; } }
public void WhenCreatedThenMessageHandlerFactoryIsSet() { var config = new HttpHostConfiguration(); config.MessageHandlerFactory = new TestMessageHandlerFactory(); var host = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri)); Assert.AreEqual(config.MessageHandlerFactory, host.MessageHandlerFactory); }
public void WhenHttpEndpointIsCreatedThenInstanceProviderBehaviorIsAdded() { var config = new HttpHostConfiguration(); config.InstanceFactory = new TestInstanceFactory(); var host = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri)); var httpEndpoint = (HttpEndpoint)host.Description.Endpoints.Find(typeof(TestService)); Assert.IsTrue(httpEndpoint.Behaviors.Contains(typeof(InstanceProviderBehavior))); }
public void WhenHttpEndpointIsCreatedThenMessageHandlerFactoryIsSet() { var config = new HttpHostConfiguration(); config.MessageHandlerFactory = new TestMessageHandlerFactory(); var host = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri)); var httpEndpoint = (HttpEndpoint)host.Description.Endpoints.Find(typeof(TestService)); Assert.AreEqual(config.MessageHandlerFactory, httpEndpoint.MessageHandlerFactory); }
public void SetUpFixture() { // Creates a new Spring context var builder = new ContainerBuilder(); builder.RegisterModule(new WebApiModule()); PopulateApplicationContext(builder); var config = HttpHostConfiguration.Create() .AddFormatters(new AtomMediaTypeFormatter()) .SetResourceFactory(new AutofacResourceFactory(builder.Build())); var type = GetServiceType(); host = new HttpConfigurableServiceHost(type, config, baseUri); host.Open(); ResourceLocation.BaseAddress = baseUri; // Create client instance client = new RestClient(baseUri, GetSerializationType()); }