public static async void ConnectNewClient() { SignalGo.Client.ClientProvider clientProvider = new SignalGo.Client.ClientProvider(); clientProvider.Connect("http://localhost:3284/TestServices/SignalGo"); ITestManager service = clientProvider.RegisterServerServiceInterfaceWrapper <ITestManager>(); string result = await service.HelloWorldAsync("ali123"); }
public async Task NormalSignalGoTestAsync() { GlobalInitalization.Initialize(); SignalGo.Client.ClientProvider clientAdmin = GlobalInitalization.InitializeAndConnecteClient(); IAuthenticationService serviceAdmin = clientAdmin.RegisterServerServiceInterfaceWrapper <IAuthenticationService>(); await TestAdminUserASync(serviceAdmin); SignalGo.Client.ClientProvider clientNormal = GlobalInitalization.InitializeAndConnecteClient(); IAuthenticationService serviceNormal = clientNormal.RegisterServerServiceInterfaceWrapper <IAuthenticationService>(); await TestNormalUserASync(serviceNormal); string adminWhatIsMyNameAmIGust = await serviceAdmin.WhatIsMyNameAsync(); Assert.IsTrue(adminWhatIsMyNameAmIGust == "admin user"); string normalWhatIsMyNameGust = await serviceNormal.WhatIsMyNameAsync(); Assert.IsTrue(normalWhatIsMyNameGust == "normal user"); adminWhatIsMyNameAmIGust = await serviceAdmin.WhatIsMyNameAsync(); Assert.IsTrue(adminWhatIsMyNameAmIGust == "admin user"); }
public void TestValidationsRule() { GlobalInitalization.Initialize(); SignalGo.Client.ClientProvider client = GlobalInitalization.InitializeAndConnecteClient(); ITestServerModel service = client.RegisterServerServiceInterfaceWrapper <ITestServerModel>(); ArticleInfo result = service.AddArticle(new ArticleInfo() { Name = "ali", Detail = "rezxa" }); Assert.IsTrue(result.CreatedDateTime.HasValue); MessageContract <ArticleInfo> resultMessage = service.AddArticleMessage(new ArticleInfo()); Assert.IsTrue(resultMessage.Errors.Count == 2); Assert.IsFalse(resultMessage.IsSuccess); }
//public static void PiplineTest() //{ // TcpListener tcpListener = new TcpListener(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), 4545); // tcpListener.Start(); // var socket = tcpListener.AcceptSocket(); //} private static async void ClientAutoReconnectTest() { SignalGo.Client.ClientProvider clientProvider = new SignalGo.Client.ClientProvider(); clientProvider.ProviderSetting.PriorityFunctionDelayTime = 0; ITestManager service = clientProvider.RegisterServerServiceInterfaceWrapper <ITestManager>(); clientProvider.RegisterClientService <ClientService>(); clientProvider.ConnectAsyncAutoReconnect("http://localhost:9752/SignalGoTestService", async(isConnected) => { try { Console.WriteLine("connection changed: " + isConnected); if (isConnected) { Console.WriteLine("sum async calling"); for (int i = 0; i < 100; i++) { int sumResult = await service.SumAsync(10, 5); await Task.Delay(1000); Console.WriteLine("sum async called: " + sumResult); } } } catch { } }); clientProvider.AddPriorityAsyncFunction(async() => { try { Console.WriteLine("HelloWorldAsync Calling"); string result = await service.HelloWorldAsync("ali123"); Console.WriteLine("HelloWorldAsync Success " + result); if (result == $"Hello ali123") { return(SignalGo.Client.PriorityAction.NoPlan); } } catch (Exception ex) { Console.WriteLine(ex); } return(SignalGo.Client.PriorityAction.TryAgain); }); }
public async Task TestAsyncs() { GlobalInitalization.Initialize(); SignalGo.Client.ClientProvider client = GlobalInitalization.InitializeAndConnecteClient(); ITestServerModel service = client.RegisterServerServiceInterfaceWrapper <ITestServerModel>(); string result = service.ServerAsyncMethod("hello"); Assert.IsTrue(result == "hello guys"); string result2 = service.ServerAsyncMethod("hello2"); Assert.IsTrue(result2 == "not found"); result = await service.ServerAsyncMethodAsync("hello"); Assert.IsTrue(result == "hello guys"); result2 = await service.ServerAsyncMethodAsync("hello2"); Assert.IsTrue(result2 == "not found"); }
public void TestDataExchanger() { GlobalInitalization.Initialize(); SignalGo.Client.ClientProvider client = GlobalInitalization.InitializeAndConnecteClient(); ITestServerModel service = client.RegisterServerServiceInterfaceWrapper <ITestServerModel>(); //while (true) // System.Threading.Thread.Sleep(100); UserInfoTest test = new UserInfoTest() { Age = 10, Id = 15, Username = "******", LastPostInfo = new PostInfoTest() { }, Password = "******", PostInfoes = new System.Collections.Generic.List <PostInfoTest>() { }, RoleInfoes = new System.Collections.Generic.List <RoleInfoTest>() { new RoleInfoTest() { } } }; UserInfoTest test1 = new UserInfoTest() { Age = 10, Id = 15, Username = "******", LastPostInfo = new PostInfoTest() { }, Password = "******", PostInfoes = new System.Collections.Generic.List <PostInfoTest>() { }, RoleInfoes = new System.Collections.Generic.List <RoleInfoTest>() { new RoleInfoTest() { Id = 5 } } }; UserInfoTest test2 = new UserInfoTest() { Age = 10, Id = 15, Username = "******", LastPostInfo = new PostInfoTest() { }, Password = "******", PostInfoes = new System.Collections.Generic.List <PostInfoTest>() { }, RoleInfoes = new System.Collections.Generic.List <RoleInfoTest>() { new RoleInfoTest() { } } }; bool helloBind = service.HelloBind(test, test1, test2); Assert.IsTrue(helloBind); System.Collections.Generic.List <UserInfoTest> users = service.GetListOfUsers(); Assert.IsTrue(string.IsNullOrEmpty(users[0].Password)); Assert.IsTrue(users[0].LastPostInfo == null); Assert.IsTrue(users[0].PostInfoes != null); Assert.IsTrue(string.IsNullOrEmpty(users[0].PostInfoes[0].PostSecurityLink)); Assert.IsTrue(users[0].PostInfoes[0].User == null); System.Collections.Generic.List <PostInfoTest> posts = service.GetPostsOfUser(1); Assert.IsTrue(string.IsNullOrEmpty(posts[0].PostSecurityLink)); Assert.IsTrue(posts[0].User == null); System.Collections.Generic.List <PostInfoTest> customPosts = service.GetCustomPostsOfUser(1); Assert.IsTrue(!string.IsNullOrEmpty(customPosts[0].PostSecurityLink)); Assert.IsTrue(customPosts[0].User == null); Assert.IsTrue(customPosts.Count == 6); Assert.IsTrue(customPosts[5].PostSecurityLink == null); Assert.IsTrue(customPosts[4].Id > 0 && customPosts[4].PostSecurityLink == null); Assert.IsTrue(string.IsNullOrEmpty(customPosts[0].Title) && string.IsNullOrEmpty(customPosts[1].Text) && customPosts[0].Id == customPosts[1].Id); System.Collections.Generic.List <UserInfoTest> customUsers = service.GetListOfUsersCustom(); Assert.IsTrue(!string.IsNullOrEmpty(customUsers[0].Password)); Assert.IsTrue(string.IsNullOrEmpty((customUsers[1].Username))); Assert.IsTrue(string.IsNullOrEmpty((customUsers[1].PostInfoes[0].PostSecurityLink))); Assert.IsTrue(!string.IsNullOrEmpty((customUsers[1].PostInfoes[0].Text))); bool loginResult = service.Login(new UserInfoTest() { Id = 1, Age = 20, LastPostInfo = new PostInfoTest() { Text = "aa" }, Username = "******", Password = "******", PostInfoes = new System.Collections.Generic.List <PostInfoTest>() { new PostInfoTest() { Text = "re" } }, RoleInfoes = new System.Collections.Generic.List <RoleInfoTest>() { new RoleInfoTest() { Type = RoleTypeTest.Admin, User = new UserInfoTest() { Username = "******" }, Id = 5 } } }); Assert.IsTrue(loginResult); }