예제 #1
0
        public void StartServerTest()
        {
            _server.Object.Start();

            Assert.True(_server.Object.IsRunning);
            Assert.Equal(_serverConfiguration.Host, _server.Object.ServerConfiguration.Host);
            Assert.Equal(_serverConfiguration.Port, _server.Object.ServerConfiguration.Port);
            Assert.Equal(_serverConfiguration.Backlog, _server.Object.ServerConfiguration.Backlog);
            Assert.Equal(_serverConfiguration.ClientBufferSize, _server.Object.ServerConfiguration.ClientBufferSize);

            _socketMock.VerifySetSocketOptions(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
            _socketMock.VerifyBind(NetHelper.CreateIpEndPoint(_serverConfiguration.Host, _serverConfiguration.Port));
            _socketMock.VerifyListen(_serverConfiguration.Backlog);
            _server.VerifyOnBeforeStart(Times.Once());
            _server.VerifyOnAfterStart(Times.Once());
            Assert.True(_server.BeforeStartCalled);
            Assert.True(_server.AfterStartCalled);
        }