示例#1
0
 public void TcpBinaryUrlValidation()
 {
     var protocol = new TcpBinaryClientProtocolSetup();
     Assert.IsTrue(protocol.IsUrlValid("tcp://localhost:123/server"));
     Assert.IsTrue(protocol.IsUrlValid("tcp://www.example.com:8080/server"));
     Assert.IsTrue(protocol.IsUrlValid("tcp://127.0.0.1:8888/index"));
     Assert.IsTrue(protocol.IsUrlValid("tcp://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index"));
     Assert.IsFalse(protocol.IsUrlValid(null));
     Assert.IsFalse(protocol.IsUrlValid(string.Empty));
     Assert.IsFalse(protocol.IsUrlValid("tcp://"));
     Assert.IsFalse(protocol.IsUrlValid("tcp://host/server"));
 }
示例#2
0
        public static int RunTest()
        {
            var protocol = new TcpBinaryClientProtocolSetup();
            protocol.AddClientSinkAfterFormatter(new CompressionClientChannelSinkProvider(1, CompressionMethod.LZF));
            _connection = new ZyanConnection("tcp://localhost:8082/TcpBinaryEventTest", protocol);

            _proxySingleton = _connection.CreateProxy<IEventComponentSingleton>();
            _proxySingleCall = _connection.CreateProxy<IEventComponentSingleCall>();
            _proxyCallbackSingleton = _connection.CreateProxy<ICallbackComponentSingleton>();
            _proxyCallbackSingleCall = _connection.CreateProxy<ICallbackComponentSingleCall>();
            _proxyRequestResponseSingleCall = _connection.CreateProxy<IRequestResponseCallbackSingleCall>();

            int successCount = 0;

            _proxyCallbackSingleton.Out_Callback = CallBackSingleton;
            _proxyCallbackSingleCall.Out_Callback = CallBackSingleCall;

            _proxyCallbackSingleton.DoSomething();
            if (_callbackCountSingleton == 1)
            {
                successCount++;
                Console.WriteLine("[TCP Binary] Singleton Callback Test passed.");
            }
            _proxyCallbackSingleCall.DoSomething();
            if (_callbackCountSingleCall == 1)
            {
                successCount++;
                Console.WriteLine("[TCP Binary] SingleCall Callback Test passed.");
            }

            RegisterEvents();
            if (_registrationsSingleton == _proxySingleton.Registrations)
                successCount++;
            if (_registrationsSingleCall == _proxySingleCall.Registrations)
                successCount++;

            _proxySingleton.TriggerEvent();
            if (_firedCountSingleton == 1)
            {
                successCount++;
                Console.WriteLine("[TCP Binary] Singleton Event Test passed.");
            }

            _proxySingleCall.TriggerEvent();
            if (_firedCountSingleCall == 1)
            {
                successCount++;
                Console.WriteLine("[TCP Binary] SingleCall Event Test passed.");
            }

            UnregisterEvents();
            if (_registrationsSingleton == _proxySingleton.Registrations)
                successCount++;
            if (_registrationsSingleCall == _proxySingleCall.Registrations)
                successCount++;

            RequestResponseResult requestResponseResult = new RequestResponseResult("TCP Binary");

            _proxyRequestResponseSingleCall.DoRequestResponse("Success", requestResponseResult.ReceiveResponseSingleCall);

            Thread.Sleep(1000);

            if (requestResponseResult.Count == 1)
                successCount++;

            _connection.Dispose();

            if (successCount == 9)
                return 0;
            else
                return 1;
        }