Exemple #1
0
        public void Shutdown_SocketIsConnected_ExecuteSocketShutdown()
        {
            // Setup the mock helper
            var mockHelper = new Mock <IP2PNodeHelper>();

            // Setup the expected method returns
            mockHelper.Setup(d => d.CloseSocket(It.IsAny <Socket>()));

            mockHelper.Setup(d => d.ShutdownSocket(It.IsAny <Socket>()));

            mockHelper.Setup(d => d.IsConnected(It.IsAny <Socket>()))
            .Returns(true);

            Byte[] someData = new Byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

            var classInTest = new P2PClientNodeHarness(mockHelper.Object);

            classInTest.Shutdown();

            mockHelper.VerifyAll();
        }
Exemple #2
0
        public void Shutdown_SocketNotConnected_SkipSocketShutdown()
        {
            // Setup the mock helper
            var mockHelper = new Mock <IP2PNodeHelper>();

            // Setup the expected method returns
            mockHelper.Setup(d => d.CloseSocket(It.IsAny <Socket>())).Verifiable();

            mockHelper.Setup(d => d.ShutdownSocket(It.IsAny <Socket>()))
            .Throws(new AssertFailedException("Shutdown socket was executed, it should of been skipped."));

            mockHelper.Setup(d => d.IsConnected(It.IsAny <Socket>()))
            .Returns(false)
            .Verifiable();

            Byte[] someData = new Byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

            var classInTest = new P2PClientNodeHarness(mockHelper.Object);

            classInTest.Shutdown();

            mockHelper.Verify();
        }