Exemple #1
0
        public void TestCloseClientReturnOne()
        {
            ClientHandler _sut     = ClientHandler.Instance;
            int           expected = 1;
            int           actual   = _sut.CloseClient(2);

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void TestServer_ClientHandler_CloseClient()
        {
            // arrange
            var mockedTcpHandler = new Mock <ITcpHandler>();
            var mockedTcpClient  = new Mock <TcpClient>();

            mockedTcpHandler.Setup(x => x.AcceptTcpClient()).Returns(mockedTcpClient.Object);
            mockedTcpHandler.Setup(x => x.CloseClient(mockedTcpClient.Object));

            // act
            ClientHandler clientHandler = new ClientHandler(mockedTcpHandler.Object);

            clientHandler.CloseClient();

            // assert
            mockedTcpHandler.Verify(x => x.AcceptTcpClient());
            mockedTcpHandler.Verify(x => x.CloseClient(mockedTcpClient.Object));
        }