Beispiel #1
0
        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)));
        }
Beispiel #2
0
        public void WhenCreatedWithAnInstanceThenServiceTypeIsSet()
        {
            var config = new HttpHostConfiguration();
            var host   = new HttpConfigurableServiceHost(new TestService(), config, new Uri(DummyUri));

            Assert.AreEqual(typeof(TestService), host.serviceType);
        }
Beispiel #3
0
        public void WhenCreatedWithATypeThenConfigurationIsSet()
        {
            var config = new HttpHostConfiguration();
            var host   = new HttpConfigurableServiceHost(typeof(TestService), config, new Uri(DummyUri));

            Assert.AreEqual(config, host.configuration);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public void TearDown()
 {
     if (host != null)
     {
         host.Close();
         host = null;
     }
 }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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)));
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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());
        }