public CreateServerInstance ( string remoteServerHostName, int port, bool useSsl, bool autoStart ) : |
||
remoteServerHostName | string | The host name for the remote server by the Stumps server. |
port | int | The TCP port used to listen for incomming HTTP requests. |
useSsl | bool | |
autoStart | bool | |
Résultat |
public void Constructor_PortNumberRange_ThrowsException() { StumpsHost proxy = new StumpsHost(Substitute.For <IServerFactory>(), Substitute.For <IDataAccess>()); Assert.That( () => proxy.CreateServerInstance("www.foo.com", IPEndPoint.MaxPort + 1, true, false), Throws.Exception.TypeOf <ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("port")); Assert.That( () => proxy.CreateServerInstance("www.foo.com", IPEndPoint.MinPort - 1, true, false), Throws.Exception.TypeOf <ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("port")); }
public void Constructor_NullHostName_ThrowsException() { StumpsHost proxy = new StumpsHost(Substitute.For<IServerFactory>(), Substitute.For<IDataAccess>()); Assert.That( () => proxy.CreateServerInstance(null, _defaultPort, true, false), Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("remoteServerHostName")); }
public void Constructor_NullHostName_ThrowsException() { StumpsHost proxy = new StumpsHost(Substitute.For <IServerFactory>(), Substitute.For <IDataAccess>()); Assert.That( () => proxy.CreateServerInstance(null, _defaultPort, true, false), Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("remoteServerHostName")); }
public void Constructor_PortInUse_ThrowsException() { int port = NetworkInformation.FindRandomOpenPort(); string externalHostName = "www.foo.com"; bool autoStart = false; bool useSsl = true; var proxyEntity = new ServerEntity { AutoStart = autoStart, RemoteServerHostName = externalHostName, Port = port, UseSsl = useSsl, ServerId = RandomGenerator.GenerateIdentifier() }; var dataAccess = Substitute.For <IDataAccess>(); dataAccess.ServerFind(Arg.Any <string>()).Returns(proxyEntity); // create a TcpListener already listening on the port var tcpListener = new TcpListener(IPAddress.Loopback, port); try { tcpListener.Start(); StumpsHost proxy = new StumpsHost(Substitute.For <IServerFactory>(), dataAccess); Assert.That( () => proxy.CreateServerInstance(externalHostName, port, useSsl, autoStart), Throws.Exception.TypeOf <StumpsNetworkException>().With.Property("Message").EqualTo("The port is already in use.")); } finally { tcpListener.Stop(); } }
public void Constructor_PortInUse_ThrowsException() { int port = NetworkInformation.FindRandomOpenPort(); string externalHostName = "www.foo.com"; bool autoStart = false; bool useSsl = true; var proxyEntity = new ServerEntity { AutoStart = autoStart, RemoteServerHostName = externalHostName, Port = port, UseSsl = useSsl, ServerId = RandomGenerator.GenerateIdentifier() }; var dataAccess = Substitute.For<IDataAccess>(); dataAccess.ServerFind(Arg.Any<string>()).Returns(proxyEntity); // create a TcpListener already listening on the port var tcpListener = new TcpListener(IPAddress.Loopback, port); try { tcpListener.Start(); StumpsHost proxy = new StumpsHost(Substitute.For<IServerFactory>(), dataAccess); Assert.That( () => proxy.CreateServerInstance(externalHostName, port, useSsl, autoStart), Throws.Exception.TypeOf<StumpsNetworkException>().With.Property("Message").EqualTo("The port is already in use.")); } finally { tcpListener.Stop(); } }
public void Constructor_PortNumberRange_ThrowsException() { StumpsHost proxy = new StumpsHost(Substitute.For<IServerFactory>(), Substitute.For<IDataAccess>()); Assert.That( () => proxy.CreateServerInstance("www.foo.com", IPEndPoint.MaxPort + 1, true, false), Throws.Exception.TypeOf<ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("port")); Assert.That( () => proxy.CreateServerInstance("www.foo.com", IPEndPoint.MinPort - 1, true, false), Throws.Exception.TypeOf<ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("port")); }