public void ServerProxy_ExecuteCommand_WhenNullPayload_ExceptionThrown()
        {
            //------------Setup for test--------------------------
            var serverProxy = new TestServerProxy();

            //------------Execute Test---------------------------
            serverProxy.ExecuteCommand(null, Guid.NewGuid());
            //------------Assert Results-------------------------
        }
        public void ServerProxy_Constructor_DefaultConstruction_ShouldHaveEsbProxyWithSendMemoSubscription()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var serverProxy = new TestServerProxy();
            //------------Assert Results-------------------------
            var subscription = serverProxy.EsbProxy.Subscribe("SendMemo");

            Assert.IsNotNull(subscription);
        }
        public void ServerProxy_Constructor_DefaultConstruction_ShouldHaveEsbProxy()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var serverProxy = new TestServerProxy();

            //------------Assert Results-------------------------
            Assert.IsNotNull(serverProxy);
            Assert.IsNotNull(serverProxy.HubConnection);
            Assert.IsNotNull(serverProxy.EsbProxy);
        }
        public void ServerProxy_IsLocalHost_DisplayNameNull_ReturnFalse()
        {
            //------------Setup for test--------------------------
            var serverProxy = new TestServerProxy
            {
                DisplayName = null
            };
            //------------Execute Test---------------------------
            var isLocalHost = serverProxy.IsLocalHost;

            //------------Assert Results-------------------------
            Assert.IsFalse(isLocalHost);
        }
        public void ServerProxy_IsLocalHost_DisplayNamelocalhostConnected_ReturnTrue()
        {
            //------------Setup for test--------------------------
            var serverProxy = new TestServerProxy
            {
                DisplayName = "localhost (Connected)"
            };
            //------------Execute Test---------------------------
            var isLocalHost = serverProxy.IsLocalHost;

            //------------Assert Results-------------------------
            Assert.IsTrue(isLocalHost);
        }
        public void ServerProxy_IsLocalHost_DisplayNameLoCaLhOst_ReturnTrue()
        {
            //------------Setup for test--------------------------
            var serverProxy = new TestServerProxy
            {
                DisplayName = "LoCaLhOst"
            };
            //------------Execute Test---------------------------
            var isLocalHost = serverProxy.IsLocalHost;

            //------------Assert Results-------------------------
            Assert.IsTrue(isLocalHost);
        }
        public void ServerProxy_Constructor_ParameterUserNamePasswordWebserverURI_ShouldHaveEsbProxy()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var serverProxy = new TestServerProxy("http://localhost:8080", "some user", "some password");

            //------------Assert Results-------------------------
            Assert.IsNotNull(serverProxy);
            Assert.IsNotNull(serverProxy.HubConnection);
            Assert.IsNotNull(serverProxy.EsbProxy);
            Assert.AreEqual("some user", serverProxy.UserName);
            Assert.AreEqual("some password", serverProxy.Password);
            Assert.AreEqual(AuthenticationType.User, serverProxy.AuthenticationType);
        }
示例#8
0
        public void ServerProxy_AddDebugWriter_WithArgs_ShouldInvokeCorrectly()
        {
            //------------Setup for test--------------------------
            var mockHubProxy = new Mock <IHubProxy>();

            mockHubProxy.Setup(proxy => proxy.Invoke("AddDebugWriter", It.IsAny <Guid>())).Returns(new Task(() => { }));
            var serverProxy = new TestServerProxy();

            serverProxy.SetEsbProxy(mockHubProxy.Object);
            //------------Execute Test---------------------------
            serverProxy.AddDebugWriter(Guid.NewGuid());
            //------------Assert Results-------------------------
            mockHubProxy.VerifyAll();
        }
        public void ServerProxy_IsLocalHost_DisplayNameEmpty_ReturnFalse()
        {
            //------------Setup for test--------------------------
            var serverProxy = new TestServerProxy
            {
                IsConnected = true,
                DisplayName = ""
            };
            //------------Execute Test---------------------------
            var isLocalHost = serverProxy.IsLocalHost;

            //------------Assert Results-------------------------
            Assert.IsTrue(serverProxy.IsConnected);
            Assert.IsFalse(isLocalHost);
        }
示例#10
0
        public void ServerProxy_ExecuteCommand_WithArgs_ShouldInvokeCorrectly()
        {
            //------------Setup for test--------------------------
            const string serverMsg    = "server result";
            var          mockHubProxy = new Mock <IHubProxyWrapper>();

            mockHubProxy.Setup(proxy => proxy.Invoke <string>("ExecuteCommand", It.IsAny <Envelope>(), It.IsAny <bool>(), It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new Task <string>(() => serverMsg));
            var serverProxy = new TestServerProxy();

            serverProxy.SetEsbProxy(mockHubProxy.Object);
            //------------Execute Test---------------------------
            var resultOfExecution = serverProxy.ExecuteCommand(new StringBuilder("some payload"), Guid.NewGuid());

            //------------Assert Results-------------------------
            mockHubProxy.VerifyAll();
            Assert.AreEqual(serverMsg, resultOfExecution.ToString());
        }
        public void ServerProxy_StateChange_FromConnectedToReconnecting_IsAuthorizedFalse()
        {
            //------------Setup for test--------------------------
            bool _permissionsChangedFired = false;

            var serverProxy = new TestServerProxy();

            serverProxy.PermissionsChanged += (sender, args) =>
            {
                _permissionsChangedFired = true;
            };
            bool authorisedBeforeStateChange = serverProxy.IsAuthorized;

            //------------Execute Test---------------------------
            serverProxy.CallHubConnectionChanged(new StateChangeWrapped(ConnectionStateWrapped.Connected, ConnectionStateWrapped.Reconnecting));
            //------------Assert Results-------------------------
            Assert.IsTrue(authorisedBeforeStateChange);
            Assert.IsFalse(serverProxy.IsAuthorized);
            Assert.IsTrue(_permissionsChangedFired);
        }
        public void ServerProxy_ConnectSetsId()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var serverProxy = new TestServerProxy();
            var x           = Guid.NewGuid();

            try
            {
                serverProxy.Connect(x);
            }
// ReSharper disable EmptyGeneralCatchClause
            catch
// ReSharper restore EmptyGeneralCatchClause
            {
            }

            //------------Assert Results-------------------------
            Assert.AreEqual(x, serverProxy.ID);
        }
示例#13
0
        public void ServerProxy_ConnectSetsId()
        {
            //------------Setup for test--------------------------
            //------------Execute Test---------------------------
            var serverProxy = new TestServerProxy();
            var x           = Guid.NewGuid();

            try
            {
                serverProxy.Connect(x);
            }

            catch

            {
            }

            //------------Assert Results-------------------------
            Assert.AreEqual(x, serverProxy.ID);
        }
示例#14
0
        public void ServerProxy_ExecuteCommand_WithArgs_ShouldInvokeCorrectly()
        {
            //------------Setup for test--------------------------
            var serverMsg      = "server result";
            var mockHubProxy   = new Mock <IHubProxy>();
            var ExpectedResult = new Receipt {
                PartID = 0, ResultParts = 1
            };

            mockHubProxy.Setup(proxy => proxy.Invoke <Receipt>("ExecuteCommand", It.IsAny <Envelope>(), It.IsAny <bool>(), It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new Task <Receipt>(() => ExpectedResult));
            mockHubProxy.Setup(proxy => proxy.Invoke <string>("FetchExecutePayloadFragment", It.IsAny <FutureReceipt>())).Returns(new Task <string>(() => serverMsg));
            var serverProxy = new TestServerProxy();

            serverProxy.SetEsbProxy(mockHubProxy.Object);
            //------------Execute Test---------------------------
            var resultOfExecution = serverProxy.ExecuteCommand(new StringBuilder("some payload"), Guid.NewGuid(), Guid.NewGuid());

            //------------Assert Results-------------------------
            mockHubProxy.VerifyAll();
            Assert.AreEqual(serverMsg, resultOfExecution.ToString());
        }
        public void ServerProxy_Wait_TaskThrowsReconnectingBeforeInvocationInvalidOperationException_ExceptionHandledAndTaskIsFaultedAndIsConnectedIsTrue()
        {
            //------------Setup for test--------------------------
            const string ExMessage = "Connection started reconnecting before invocation result was received";
            var          result    = new StringBuilder();
            var          task      = new Task <string>(() =>
            {
                throw new InvalidOperationException(ExMessage);
            });

            var serverProxy = new TestServerProxy
            {
                IsConnected = true
            };

            //------------Execute Test---------------------------
            serverProxy.TestWait(task, result);

            //------------Assert Results-------------------------
            StringAssert.Contains(result.ToString(), ExMessage);
            Assert.IsTrue(task.IsFaulted);
            Assert.IsTrue(serverProxy.IsConnected);
        }
        public void ServerProxy_Wait_TaskThrowsHttpClientException_ExceptionHandledAndTaskIsFaultedAndIsConnectedIsTrue()
        {
            //------------Setup for test--------------------------
            const string ExMessage = "StatusCode: 403";
            var          result    = new StringBuilder();
            var          task      = new Task <string>(() =>
            {
                throw new HttpClientException(ExMessage);
            });


            var serverProxy = new TestServerProxy
            {
                IsConnected = true
            };

            //------------Execute Test---------------------------
            serverProxy.TestWait(task, result);

            //------------Assert Results-------------------------
            StringAssert.Contains(result.ToString(), ExMessage);
            Assert.IsTrue(task.IsFaulted);
            Assert.IsTrue(serverProxy.IsConnected);
        }