public void MultipleUrlsSpecified() { var startOptions = new StartOptions(); startOptions.Urls.Add("beta://localhost:3333"); startOptions.Urls.Add("delta://foo/"); startOptions.Urls.Add("gama://*:4444/"); startOptions.Port = 1111; // Ignored because of Url(s) var serverFactory = new ServerFactoryAlpha(); var startInfo = new StartContext(startOptions); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactory); startInfo.App = new AppFunc(env => Task.FromResult(0)); var engine = ServicesFactory.Create().GetService <IHostingEngine>(); serverFactory.InitializeCalled.ShouldBe(false); serverFactory.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactory.InitializeProperties["host.Addresses"].ShouldBeTypeOf <IList <IDictionary <string, object> > >(); var addresses = (IList <IDictionary <string, object> >)serverFactory.InitializeProperties["host.Addresses"]; Assert.Equal(3, addresses.Count); var expectedAddresses = new[] { new[] { "beta", "localhost", "3333", string.Empty }, new[] { "delta", "foo", string.Empty, "/" }, new[] { "gama", "*", "4444", "/" }, }; for (int i = 0; i < addresses.Count; i++) { IDictionary <string, object> addressDictionary = addresses[i]; string[] expectedValues = expectedAddresses[i]; Assert.Equal(expectedValues.Length, addressDictionary.Count); Assert.Equal(expectedValues[0], (string)addressDictionary["scheme"]); Assert.Equal(expectedValues[1], (string)addressDictionary["host"]); Assert.Equal(expectedValues[2], (string)addressDictionary["port"]); Assert.Equal(expectedValues[3], (string)addressDictionary["path"]); } server.Dispose(); }
public void InitializeAndCreateShouldBeCalledWithProperties() { var serverFactoryAlpha = new ServerFactoryAlpha(); var startInfo = new StartContext(new StartOptions()); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactoryAlpha); startInfo.App = new AppFunc(env => Task.FromResult(0)); var engine = ServicesFactory.Create().GetService<IHostingEngine>(); serverFactoryAlpha.InitializeCalled.ShouldBe(false); serverFactoryAlpha.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactoryAlpha.InitializeCalled.ShouldBe(true); serverFactoryAlpha.CreateCalled.ShouldBe(true); serverFactoryAlpha.InitializeProperties.ShouldBeSameAs(serverFactoryAlpha.CreateProperties); server.Dispose(); }
public void InitializeAndCreateShouldBeCalledWithProperties() { var serverFactoryAlpha = new ServerFactoryAlpha(); var startInfo = new StartContext(new StartOptions()); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactoryAlpha); startInfo.App = new AppFunc(env => Task.FromResult(0)); var engine = ServicesFactory.Create().GetService <IHostingEngine>(); serverFactoryAlpha.InitializeCalled.ShouldBe(false); serverFactoryAlpha.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactoryAlpha.InitializeCalled.ShouldBe(true); serverFactoryAlpha.CreateCalled.ShouldBe(true); serverFactoryAlpha.InitializeProperties.ShouldBeSameAs(serverFactoryAlpha.CreateProperties); server.Dispose(); }
public void PropertiesShouldHaveExpectedKeysFromHost() { var serverFactory = new ServerFactoryAlpha(); var startInfo = new StartContext(new StartOptions()); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactory); startInfo.App = new AppFunc(env => Task.FromResult(0)); var engine = ServicesFactory.Create().GetService <IHostingEngine>(); serverFactory.InitializeCalled.ShouldBe(false); serverFactory.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactory.InitializeProperties.ShouldContainKey("host.TraceOutput"); serverFactory.InitializeProperties.ShouldContainKey("host.Addresses"); serverFactory.InitializeProperties["host.TraceOutput"].ShouldBeTypeOf <TextWriter>(); serverFactory.InitializeProperties["host.Addresses"].ShouldBeTypeOf <IList <IDictionary <string, object> > >(); server.Dispose(); }
public void MultipleUrlsSpecified() { StartOptions startOptions = new StartOptions(); startOptions.Urls.Add("beta://localhost:3333"); startOptions.Urls.Add("delta://foo/"); startOptions.Urls.Add("gama://*:4444/"); startOptions.Port = 1111; // Ignored because of Url(s) var serverFactory = new ServerFactoryAlpha(); var startInfo = new StartContext(startOptions); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactory); startInfo.App = new AppFunc(env => TaskHelpers.Completed()); var engine = ServicesFactory.Create().GetService<IHostingEngine>(); serverFactory.InitializeCalled.ShouldBe(false); serverFactory.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactory.InitializeProperties["host.Addresses"].ShouldBeTypeOf<IList<IDictionary<string, object>>>(); var addresses = (IList<IDictionary<string, object>>)serverFactory.InitializeProperties["host.Addresses"]; Assert.Equal(3, addresses.Count); string[][] expectedAddresses = new[] { new[] { "beta", "localhost", "3333", string.Empty }, new[] { "delta", "foo", string.Empty, "/" }, new[] { "gama", "*", "4444", "/" }, }; for (int i = 0; i < addresses.Count; i++) { var addressDictionary = addresses[i]; var expectedValues = expectedAddresses[i]; Assert.Equal(expectedValues.Length, addressDictionary.Count); Assert.Equal(expectedValues[0], (string)addressDictionary["scheme"]); Assert.Equal(expectedValues[1], (string)addressDictionary["host"]); Assert.Equal(expectedValues[2], (string)addressDictionary["port"]); Assert.Equal(expectedValues[3], (string)addressDictionary["path"]); } server.Dispose(); }
public void PropertiesShouldHaveExpectedKeysFromHost() { var serverFactory = new ServerFactoryAlpha(); var startInfo = new StartContext(new StartOptions()); startInfo.ServerFactory = new ServerFactoryAdapter(serverFactory); startInfo.App = new AppFunc(env => TaskHelpers.Completed()); var engine = ServicesFactory.Create().GetService<IHostingEngine>(); serverFactory.InitializeCalled.ShouldBe(false); serverFactory.CreateCalled.ShouldBe(false); IDisposable server = engine.Start(startInfo); serverFactory.InitializeProperties.ShouldContainKey("host.TraceOutput"); serverFactory.InitializeProperties.ShouldContainKey("host.Addresses"); serverFactory.InitializeProperties["host.TraceOutput"].ShouldBeTypeOf<TextWriter>(); serverFactory.InitializeProperties["host.Addresses"].ShouldBeTypeOf<IList<IDictionary<string, object>>>(); server.Dispose(); }