public void IpcUrlValidation() { var protocol = new IpcBinaryClientProtocolSetup(); Assert.IsTrue(protocol.IsUrlValid("ipc://portName/serviceName")); Assert.IsFalse(protocol.IsUrlValid(null)); Assert.IsFalse(protocol.IsUrlValid(string.Empty)); Assert.IsFalse(protocol.IsUrlValid("ipc://")); }
public static int RunTest() { var protocol = new IpcBinaryClientProtocolSetup(); protocol.AddClientSinkAfterFormatter(new CompressionClientChannelSinkProvider(1, CompressionMethod.LZF)); _connection = new ZyanConnection("ipc://IpcTestServer/IpcBinaryEventTest", 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("[IPC Binary] Singleton Callback Test passed."); } _proxyCallbackSingleCall.DoSomething(); if (_callbackCountSingleCall == 1) { successCount++; Console.WriteLine("[IPC Binary] SingleCall Callback Test passed."); } RegisterEvents(); if (_registrationsSingleton == _proxySingleton.Registrations) successCount++; if (_registrationsSingleCall == _proxySingleCall.Registrations) successCount++; _proxySingleton.TriggerEvent(); if (_firedCountSingleton == 1) { successCount++; Console.WriteLine("[IPC Binary] Singleton Event Test passed."); } _proxySingleCall.TriggerEvent(); if (_firedCountSingleCall == 1) { successCount++; Console.WriteLine("[IPC Binary] SingleCall Event Test passed."); } UnregisterEvents(); if (_registrationsSingleton == _proxySingleton.Registrations) successCount++; if (_registrationsSingleCall == _proxySingleCall.Registrations) successCount++; RequestResponseResult requestResponseResult = new RequestResponseResult("IPC Binary"); _proxyRequestResponseSingleCall.DoRequestResponse("Success", requestResponseResult.ReceiveResponseSingleCall); Thread.Sleep(1000); if (requestResponseResult.Count == 1) successCount++; _connection.Dispose(); if (successCount == 9) return 0; else return 1; }
public static void StartServer(TestContext ctx) { ZyanConnection.AllowUrlRandomization = false; var serverSetup = new IpcBinaryServerProtocolSetup("ZyanProxyTest"); ZyanHost = new ZyanComponentHost("ZyanProxyServer", serverSetup); ZyanHost.RegisterComponent<ISampleServer, SampleServer>(ActivationType.Singleton); var clientSetup = new IpcBinaryClientProtocolSetup(); ZyanConnection = new ZyanConnection("ipc://ZyanProxyTest/ZyanProxyServer", clientSetup); }
public void TestGenericWrapperOverZyan() { var serverProto = new IpcBinaryServerProtocolSetup("Test"); var clientProto = new IpcBinaryClientProtocolSetup(); var host = new ZyanComponentHost("TestServer", serverProto); host.RegisterComponent<INonGenericInterface>(() => new NonGenericWrapper(new GenericClass()), ActivationType.Singleton); var conn = new ZyanConnection("ipc://Test/TestServer"); var proxy = conn.CreateProxy<INonGenericInterface>(); // same as usual var test = new GenericWrapper(proxy); var prioritySet = false; // GetDefault Assert.AreEqual(default(int), test.GetDefault<int>()); Assert.AreEqual(default(string), test.GetDefault<string>()); Assert.AreEqual(default(Guid), test.GetDefault<Guid>()); // Equals Assert.IsTrue(test.Equals(123, 123)); Assert.IsFalse(test.Equals("Some", null)); // GetVersion Assert.AreEqual("DoSomething wasn't called yet", test.GetVersion()); // DoSomething test.DoSomething(123, 'x', "y"); Assert.AreEqual("DoSomething: A = 123, B = x, C = y", test.GetVersion()); // Compute var dt = test.Compute<Guid, DateTime>(Guid.Empty, 123, "123"); Assert.AreEqual(default(DateTime), dt); // CreateGuid var guid = test.CreateGuid(dt, 12345); Assert.AreEqual("00003039-0001-0001-0000-000000000000", guid.ToString()); // LastDate Assert.AreEqual(dt, test.LastDate); test.LastDate = dt = DateTime.Now; Assert.AreEqual(dt, test.LastDate); // Name Assert.AreEqual("GenericClass, priority = 123", test.Name); // add OnPrioritySet EventHandler<EventArgs> handler = (s, a) => prioritySet = true; test.OnPrioritySet += handler; Assert.IsFalse(prioritySet); // Priority test.Priority = 321; Assert.IsTrue(prioritySet); Assert.AreEqual("GenericClass, priority = 321", test.Name); // remove OnPrioritySet prioritySet = false; test.OnPrioritySet -= handler; test.Priority = 111; Assert.IsFalse(prioritySet); }