Esempio n. 1
0
        public void CollabProxyClient_InstantiatedWithoutPortCache_HasValidConnection()
        {
            var theClient = new TestableCollabProxyClient();

            theClient.StartOrConnectToServer();
            Assert.IsTrue(theClient.IsConnected());
        }
Esempio n. 2
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());
        }
Esempio n. 3
0
        public void CollabProxyClient_InstantiatedWithGoodPortCache_HasValidConnection()
        {
            var firstClient = new TestableCollabProxyClient();

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

            secondClient.StartOrConnectToServer();
            Assert.IsTrue(secondClient.IsConnected());
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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");
        }
Esempio n. 9
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);
        }