Exemple #1
0
        public async Task TestDataExchangerAsync()
        {
            GlobalInitalization.Initialize();
            SignalGo.Client.ClientProvider client = GlobalInitalization.InitializeAndConnecteClient();

            ITestServerModel service = client.RegisterServerServiceInterfaceWrapper <ITestServerModel>();
            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 = await service.HelloBindAsync(test, test1, test2);

            Assert.IsTrue(helloBind);
            System.Collections.Generic.List <UserInfoTest> users = await service.GetListOfUsersAsync();

            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 = await service.GetPostsOfUserAsync(1);

            Assert.IsTrue(string.IsNullOrEmpty(posts[0].PostSecurityLink));
            Assert.IsTrue(posts[0].User == null);

            System.Collections.Generic.List <PostInfoTest> customPosts = await service.GetCustomPostsOfUserAsync(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 = await service.GetListOfUsersCustomAsync();

            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 = await service.LoginAsync(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);
        }