CreateServerInstance() public méthode

Creates a new instance of a Stumps server.
is null. exceeds the allowed TCP port range. The port is already in use.
public CreateServerInstance ( string remoteServerHostName, int port, bool useSsl, bool autoStart ) : StumpsServerInstance
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 true if the remote server requires SSL.
autoStart bool true to automatically start the Stumps server.
Résultat StumpsServerInstance
        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"));
        }
Exemple #2
0
 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();
            }
        }
Exemple #5
0
        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();
            }
        }
Exemple #6
0
        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"));
        }