Пример #1
0
        public void CollabProxyClient_InstantiatedWithoutPortCache_HasValidConnection()
        {
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            Assert.IsTrue(theClient.IsConnected());
        }
Пример #2
0
        public void CollabProxyClient_InstantiatedWithGoodPortCache_DoesNotCacheNewPort()
        {
            var firstClient  = new TestableCollabProxyClient();
            var firstPort    = TestHelper.GetPortFromFile();
            var secondClient = new TestableCollabProxyClient();
            var secondPort   = TestHelper.GetPortFromFile();

            Assert.AreEqual(firstPort, secondPort);
        }
Пример #3
0
        public void CollabProxyClient_InstantiatedWithoutPortCache_CachesNewPort()
        {
            Assert.IsFalse(File.Exists(CollabProxyClient.GetPortFilePath()));
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            Assert.IsTrue(File.Exists(CollabProxyClient.GetPortFilePath()));
            Assert.AreNotEqual(0, TestHelper.GetPortFromFile());
        }
Пример #4
0
        public void CollabProxyClient_InstantiatedWithGoodPortCache_HasValidConnection()
        {
            var firstClient = new TestableCollabProxyClient();

            firstClient.StartOrConnectToServer();
            var secondClient = new TestableCollabProxyClient();

            secondClient.StartOrConnectToServer();
            Assert.IsTrue(secondClient.IsConnected());
        }
Пример #5
0
        public void CollabProxyClient_InstantiatedWithBadPortCache_CachesNewPort()
        {
            var firstClient = new TestableCollabProxyClient();

            firstClient.StartOrConnectToServer();
            Connection.StopListening();
            TestableCollabProxyClient.ResetPort(k_ResetPortValue);
            var secondClient = new TestableCollabProxyClient();

            secondClient.StartOrConnectToServer();
            var secondPort = TestHelper.GetPortFromFile();

            Assert.AreNotEqual(k_ResetPortValue, secondPort);
        }
Пример #6
0
        public void SetRemoteOrigin_WhenCalled_SendsTcpMessage()
        {
            var methodCalled = false;

            TestHelper.RegisterListener("setremoteorigin", val => methodCalled = true);
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            IGitProxy theProxy = new GitProxy(theClient);

            // Make sure nothing happened up to this point
            Assert.IsFalse(methodCalled);
            theProxy.SetRemoteOrigin("");
            Assert.IsTrue(methodCalled);
        }
Пример #7
0
        public void InitializeRepository_WhenCalled_SendsTcpMessage()
        {
            var methodCalled = false;

            TestHelper.RegisterListener("initializerepository", val => methodCalled = true);
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            IGitProxy theProxy = new GitProxy(theClient);

            // Make sure nothing happened up to this point
            Assert.IsFalse(methodCalled);
            theProxy.InitializeRepository();
            Assert.IsTrue(methodCalled);
        }
Пример #8
0
        public void CallSynchronous_WhenCalledWithoutParams_SendsTcpMessageWithoutParams()
        {
            var result       = "";
            var methodCalled = false;
            var theClient    = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            // Register a listener on the TCP connection
            TestHelper.RegisterListener("randomness", val =>
            {
                methodCalled = true;
                result       = val;
            });
            theClient.CallSynchronous("Randomness");
            Assert.IsTrue(methodCalled);
            Assert.AreEqual("", result);
        }
Пример #9
0
        public void CallSynchronous_WhenCalledWithParams_SendsTcpMessageWithParams()
        {
            var result       = "";
            var methodCalled = false;
            var theClient    = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            // Register a listener on the TCP connection
            TestHelper.RegisterListener("randomness", val =>
            {
                methodCalled = true;
                result       = val;
            });
            theClient.CallSynchronous("Randomness", "foo", "bar");
            Assert.IsTrue(methodCalled);
            var objects = Serialization.Deserialize <Object[]>(result);

            Assert.AreEqual(objects[0], "foo");
            Assert.AreEqual(objects[1], "bar");
        }
Пример #10
0
        public void GetWorkingDirectoryChangesAsync_WhenCalled_SendsTcpMessage()
        {
            var methodCalled = false;
            var resetHandle  = new ManualResetEvent(false);

            TestHelper.RegisterListener("GetWorkingDirectoryChangesAsync".ToLower(), val =>
            {
                methodCalled = true;
                resetHandle.Set();
            });
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            IGitProxy theProxy = new GitProxy(theClient);

            // Make sure nothing happened up to this point
            Assert.IsFalse(methodCalled);
            theProxy.GetWorkingDirectoryChangesAsync();
            resetHandle.WaitOne();
            Assert.IsTrue(methodCalled);
        }