예제 #1
0
        public T WithCustomPort(int portNumber)
        {
            ScenarioRepository.Unregister(_portNumber);

            _portNumber = portNumber;

            ScenarioRepository.Register(_portNumber, this);

            return((T)this);
        }
예제 #2
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var portNumber =
                Int32.Parse(
                    (string)((IList <IDictionary <string, object> >)appBuilder.Properties["host.Addresses"])[0]["port"]);

            _scenario = ScenarioRepository.GetScenario(portNumber) as MockScenario;

            appBuilder.Use(typeof(LoggingMiddleware));

            appBuilder.Run(Invoke);
        }
예제 #3
0
        internal ScenarioBase()
        {
            _portNumber = PortRepository.GetFreePortNumber();

            ScenarioRepository.Register(_portNumber, this);

            Container = new UnityContainer();

            _httpConfiguration = new HttpConfiguration
            {
                DependencyResolver = new UnityDependencyResolver(Container)
            };
        }
예제 #4
0
        // This code configures Web API. The WebApiStartup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            var portNumber =
                Int32.Parse(
                    (string)((IList <IDictionary <string, object> >)appBuilder.Properties["host.Addresses"])[0]["port"]);

            var configuration = ScenarioRepository.GetHttpConfiguration(portNumber);

            if (configuration == null)
            {
                configuration = new HttpConfiguration();

                WebApiConfig.Register(configuration);
            }

            appBuilder.UseWebApi(configuration);
        }
예제 #5
0
        public void Dispose()
        {
            _host.Dispose();

            ScenarioRepository.Unregister(_portNumber);
        }