Пример #1
0
        public void Comments_GetComments_ContainsPagingInformation()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList <Comment> received  = null;
                ApiException         exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetComments(22656, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                       error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsTrue(received.PageSize > 0));
                EnqueueCallback(() => Assert.IsTrue(received.CurrentPage > 0));
                EnqueueCallback(() => Assert.IsTrue(received.TotalItems > 0));
            }
        }
Пример #2
0
        public void Question_GetQuestionTimeline()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IEnumerable <PostEvent> received  = null;
                ApiException            exception = null;
                bool completed = false;

                EnqueueCallback(() =>
                {
                    Client.GetQuestionTimeline(31415, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                               error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #3
0
        public void Question_GetQuestion_ContainsOwner()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question     received  = null;
                ApiException exception = null;
                bool         completed = false;

                Client.GetQuestion(2930182, results =>
                {
                    received  = results;
                    completed = true;
                },
                                   error =>
                {
                    exception = error;
                    completed = true;
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.Owner));
                EnqueueCallback(() => Assert.IsTrue(received.Owner.UserId.HasValue));
            }
        }
Пример #4
0
        public void Answer_GetAnswer()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Answer       received  = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetAnswer(11738, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                     error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #5
0
        public void Question_Contains_Urls()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question     received  = null;
                ApiException exception = null;
                bool         completed = false;

                EnqueueCallback(() =>
                {
                    Client.GetQuestion(31415, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                       error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });

                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsFalse(String.IsNullOrEmpty(received.CommentsUrl)));
                EnqueueCallback(() => Assert.IsFalse(String.IsNullOrEmpty(received.TimelineUrl)));
            }
        }
Пример #6
0
        public void GetAnswerComments()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList<Comment> received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetAnswerComments(1330865, results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.AreEqual(PostType.Answer, received.FirstOrDefault().PostType));
            }
        }
Пример #7
0
        public void Question_Search()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList <Question> received  = null;
                ApiException          exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.Search(results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                  error =>
                    {
                        exception = error;
                        completed = true;
                    }, inTitle: "Thread");
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #8
0
        public void Comments_GetComments()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IEnumerable<Comment> received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetComments(22656, results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #9
0
        public void Comments_GetComments_ContainsPagingInformation()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList<Comment> received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetComments(22656, results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsTrue(received.PageSize > 0));
                EnqueueCallback(() => Assert.IsTrue(received.CurrentPage > 0));
                EnqueueCallback(() => Assert.IsTrue(received.TotalItems > 0));
            }
        }
Пример #10
0
        public void Revision_GetRevision()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Revision     received  = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetRevision(31415, Guid.Parse("5a1fd2ac-421a-43a9-a2a3-2e9b5afe1b23"), results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                       error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #11
0
        public void ContainsSite()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                SiteStats received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetSiteStats(results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.Site));
            }
        }
Пример #12
0
        public void Badge_GetUsersByBadge()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList <User> received  = null;
                ApiException      exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetUsersByBadge(204, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                           error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #13
0
        public void Revision_GetRevision()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Revision received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetRevision(31415, Guid.Parse("5a1fd2ac-421a-43a9-a2a3-2e9b5afe1b23"), results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #14
0
        public void Answer_GetAnswers()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList <Answer> received  = null;
                ApiException        exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetAnswers(new int[] { 11738, 122784 }, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                      error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsTrue(received.PageSize > 0));
                EnqueueCallback(() => Assert.IsTrue(received.CurrentPage > 0));
                EnqueueCallback(() => Assert.IsTrue(received.TotalItems > 0));
            }
        }
Пример #15
0
        public void GetCommentsByPost_ByQuestionId()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList <Comment> received  = null;
                ApiException         exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetCommentsByPost(9033, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                             error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.AreEqual(PostType.Question, received.FirstOrDefault().PostType));
            }
        }
Пример #16
0
        public void MigratedQuestion_CanDeserialize()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question     received  = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetQuestion(970696, results =>
                    {
                        received  = results;
                        completed = true;
                    },
                                       error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.Migrated));
                EnqueueCallback(() => Assert.IsNotNull(received.Migrated.ToSite));
            }
        }
Пример #17
0
        public void User_GetUsers()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList<User> received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetUsers(results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #18
0
        public void Answer_Contains_Comments_Url()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Answer       received  = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetUsersAnswers(1464, results =>
                    {
                        received  = results.FirstOrDefault();
                        completed = true;
                    },
                                           error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.CommentsUrl));
            }
        }
Пример #19
0
        public void Question_Contains_Urls()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question received = null;
                ApiException exception = null;
                bool completed = false;

                EnqueueCallback(() =>
                {
                    Client.GetQuestion(31415, results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });

                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsFalse(String.IsNullOrEmpty(received.CommentsUrl)));
                EnqueueCallback(() => Assert.IsFalse(String.IsNullOrEmpty(received.TimelineUrl)));
            }
        }
Пример #20
0
        public void MigratedQuestion_CanDeserialize()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.GetQuestion(970696, results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    });
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.Migrated));
                EnqueueCallback(() => Assert.IsNotNull(received.Migrated.ToSite));
            }
        }
Пример #21
0
        public void Question_Search()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                IPagedList<Question> received = null;
                ApiException exception = null;

                bool completed = false;
                EnqueueCallback(() =>
                {
                    Client.Search(results =>
                    {
                        received = results;
                        completed = true;
                    },
                    error =>
                    {
                        exception = error;
                        completed = true;
                    }, inTitle: "Thread");
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
            }
        }
Пример #22
0
        public void Question_GetQuestion_ContainsOwner()
        {
            using (var context = new AsynchronusTestContext(this))
            {
                Question received = null;
                ApiException exception = null;
                bool completed = false;

                Client.GetQuestion(2930182, results =>
                {
                    received = results;
                    completed = true;
                },
                error =>
                {
                    exception = error;
                    completed = true;
                });
                EnqueueConditional(() => completed);
                EnqueueCallback(() => Assert.IsNull(exception));
                EnqueueCallback(() => Assert.IsNotNull(received));
                EnqueueCallback(() => Assert.IsNotNull(received.Owner));
                EnqueueCallback(() => Assert.IsTrue(received.Owner.UserId.HasValue));
            }
        }