Example #1
0
        public void StopServer_ThrowsExceptionIfServerWasNotStarted()
        {
            using var testedServer = new NetTcpListenerBasedTcpServer();
            Action stopping = () => testedServer.StopServer();

            stopping.Should().ThrowExactly <TcpServerStopException>().WithMessage("This TCP server has not been started yet.");
        }
Example #2
0
        public async Task StartServer_ThrowsExceptionIfServerIsAlreadyStarted()
        {
            using var testedServer = new NetTcpListenerBasedTcpServer();
            Func <Task> starting = async() => await testedServer.StartServer();

            await starting();

            await starting.Should().ThrowExactlyAsync <TcpServerStartException>().WithMessage("This TCP server has already been started.");
        }
Example #3
0
        public async Task StopServer_ThrowsExceptionIfServerIsStoppedTwice()
        {
            using var testedServer = new NetTcpListenerBasedTcpServer();
            Action stopping = () => testedServer.StopServer();
            await testedServer.StartServer();

            stopping();

            stopping.Should().ThrowExactly <TcpServerStopException>().WithMessage("This TCP server has not been started yet.");
        }
Example #4
0
        public async Task StartServer_CanBeStartedAgainAfterHasBeenStopped()
        {
            using var testedServer = new NetTcpListenerBasedTcpServer();
            Func <Task> starting = async() => await testedServer.StartServer();

            await starting();

            testedServer.StopServer();

            await starting.Should().NotThrowAsync();
        }