示例#1
0
        private IDisposable CreateListener(int port)
        {
            var appProperties = new AppProperties(new Dictionary <string, object>())
            {
                Addresses = AddressCollection.Create()
            };

            var address = Address.Create();

            address.Scheme = "http";
            address.Host   = "localhost";
            address.Port   = port.ToString();
            address.Path   = "/sonarlint/api/";
            appProperties.Addresses.Add(address);

            // Create a new Owin HTTPListener that forwards all requests to our processor for handling.
            return(OwinServerFactory.Create(requestProcessor.ProcessRequest, appProperties.Dictionary));
        }
        public void AddressCollectionOperations()
        {
            IDictionary <string, object> properties = new Dictionary <string, object>();
            AppProperties appProperties             = new AppProperties(properties);

            appProperties.Addresses = AddressCollection.Create();
            appProperties.Addresses.Add(new Address("http", "*", "80", "/"));

            Assert.Equal(1, appProperties.Addresses.Count);
            Assert.Equal("http", appProperties.Addresses[0].Scheme);

            foreach (Address address in appProperties.Addresses)
            {
                Assert.Equal("http", address.Scheme);
                Assert.Equal("*", address.Host);
                Assert.Equal("80", address.Port);
                Assert.Equal("/", address.Path);
            }
        }