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 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");
        }
Beispiel #3
0
        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);
        }