Пример #1
0
        public static int RunTest()
        {
            var protocol = new TcpCustomClientProtocolSetup(true)
            {
                CompressionThreshold = 1, // compress data packets of any size
                CompressionMethod = CompressionMethod.LZF
            };

            _connection = new ZyanConnection("tcp://localhost:8083/TcpCustomEventTest", 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 Custom] Singleton Callback Test passed.");
            }
            _proxyCallbackSingleCall.DoSomething();
            if (_callbackCountSingleCall == 1)
            {
                successCount++;
                Console.WriteLine("[TCP Custom] SingleCall Callback Test passed.");
            }

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

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

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

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

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

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

            Thread.Sleep(1000);

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

            _connection.Dispose();

            if (successCount == 9)
                return 0;
            else
                return 1;
        }
Пример #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;
        }
Пример #3
0
        public static int Main(string[] args)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _serverAppDomain = AppDomain.CreateDomain("Server", null, setup);
            _serverAppDomain.Load("Zyan.Communication");

            CrossAppDomainDelegate serverWork = new CrossAppDomainDelegate(() =>
            {
                EventServer server = EventServer.Instance;
            });
            _serverAppDomain.DoCallBack(serverWork);

            //TcpCustomClientProtocolSetup protocol = new TcpCustomClientProtocolSetup(true);
            MsmqClientProtocolSetup protocol = new MsmqClientProtocolSetup();
            //_connection = new ZyanConnection("tcp://localhost:8083/EventTest",protocol);
            _connection = new ZyanConnection(@"msmq://private$/reqchannel/EventTest", 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("Singleton Callback Test passed.");
            }
            _proxyCallbackSingleCall.DoSomething();
            if (_callbackCountSingleCall == 1)
            {
                successCount++;
                Console.WriteLine("SingleCall Callback Test passed.");
            }

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

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

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

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

            RequestResponseResult requestResponseResult = new RequestResponseResult();

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

            Thread.Sleep(1000);

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

            _connection.Dispose();
            EventServerLocator locator = _serverAppDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "IntegrationTest_DistributedEvents.EventServerLocator") as EventServerLocator;
            locator.GetEventServer().Dispose();
            AppDomain.Unload(_serverAppDomain);

            if (successCount == 9)
                return 0;
            else
                return 1;
        }
Пример #4
0
        public static int RunTest()
        {
            // Duplex TCP Channel
            var protocol = new TcpDuplexClientProtocolSetup(true)
            {
                CompressionThreshold = 1, // compress data packets of any size
                CompressionMethod = CompressionMethod.DeflateStream
            };

            _connectionDuplex = new ZyanConnection("tcpex://localhost:8084/TcpDuplexEventTest", protocol);

            _proxySingletonDuplex = _connectionDuplex.CreateProxy<IEventComponentSingleton>();
            _proxySingleCallDuplex = _connectionDuplex.CreateProxy<IEventComponentSingleCall>();
            _proxyCallbackSingletonDuplex = _connectionDuplex.CreateProxy<ICallbackComponentSingleton>();
            _proxyCallbackSingleCallDuplex = _connectionDuplex.CreateProxy<ICallbackComponentSingleCall>();
            _proxyRequestResponseSingleCallDuplex = _connectionDuplex.CreateProxy<IRequestResponseCallbackSingleCall>();
            _proxyTimerTriggeredEvent = _connectionDuplex.CreateProxy<ITimerTriggeredEvent>();

            _proxyTimerTriggeredEvent.StartTimer();

            List<int> stepsDone = new List<int>();

            _proxyCallbackSingletonDuplex.Out_Callback = CallBackSingletonDuplex;
            _proxyCallbackSingleCallDuplex.Out_Callback = CallBackSingleCallDuplex;

            _proxyCallbackSingletonDuplex.DoSomething();
            if (_callbackCountSingletonDuplex == 1)
            {
                stepsDone.Add(1);
                Console.WriteLine("[TCP Duplex] Singleton Callback Test passed.");
            }
            _proxyCallbackSingleCallDuplex.DoSomething();
            if (_callbackCountSingleCallDuplex == 1)
            {
                stepsDone.Add(2);
                Console.WriteLine("[TCP Duplex] SingleCall Callback Test passed.");
            }

            RegisterEventsDuplex();

            if (_registrationsSingletonDuplex == _proxySingletonDuplex.Registrations)
                stepsDone.Add(3);
            if (_registrationsSingleCallDuplex == _proxySingleCallDuplex.Registrations)
                stepsDone.Add(4);

            _proxySingletonDuplex.TriggerEvent();
            if (_firedCountSingletonDuplex == 1)
            {
                stepsDone.Add(5);
                Console.WriteLine("[TCP Duplex] Singleton Event Test passed.");
            }

            _proxySingleCallDuplex.TriggerEvent();
            if (_firedCountSingleCallDuplex == 1)
            {
                stepsDone.Add(6);
                Console.WriteLine("[TCP Duplex] SingleCall Event Test passed.");
            }

            Thread.Sleep(1000);

            if (_firedTimerTriggeredEvent > 1)
            {
                stepsDone.Add(7);
                Console.WriteLine("[TCP Duplex] Timer triggered Event Test passed.");
            }

            UnregisterEventsDuplex();

            if (_registrationsSingletonDuplex == _proxySingletonDuplex.Registrations)
                stepsDone.Add(8);
            if (_registrationsSingleCallDuplex == _proxySingleCallDuplex.Registrations)
                stepsDone.Add(9);

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

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

            Thread.Sleep(1000);

            if (requestResponseResult.Count == 1)
                stepsDone.Add(10);

            _connectionDuplex.Dispose();

            if (stepsDone.Count == 10)
                return 0;
            else
                return 1;
        }
Пример #5
0
        public static int RunTest()
        {
            var protocol = new NullClientProtocolSetup();

            _connection = new ZyanConnection("null://NullChannel:1234/NullEventTest", 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("[NULL Channel] Singleton Callback Test passed.");
            }
            _proxyCallbackSingleCall.DoSomething();
            if (_callbackCountSingleCall == 1)
            {
                successCount++;
                Console.WriteLine("[NULL Channel] SingleCall Callback Test passed.");
            }

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

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

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

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

            RequestResponseResult requestResponseResult = new RequestResponseResult("NULL Channel");

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

            Thread.Sleep(1000);

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

            _connection.Dispose();

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