Пример #1
0
        public void CreateReplyPostTest()
        {
            CreateTopPostTest();
            var authorId = CreateAccountId();
            var postInfo = new PostInfo(null, RandomString(), PostId, PostId, Guid.NewGuid(), authorId);

            ResetWaiters();
            PostId = Guid.Empty;
            Post post = null;

            _commandService.Send(new CreatePost {
                PostInfo = postInfo
            }, (result) =>
            {
                Assert.IsFalse(result.HasError);
                EventHandlerWaiter.WaitOne();
                post = _memoryCache.Get <Post>(PostId.ToString());
                TestThreadWaiter.Set();
            });

            TestThreadWaiter.WaitOne(500);
            Assert.NotNull(post);
            Assert.NotNull(post.ParentId);
            Assert.AreEqual(postInfo.Subject, post.Subject);
            Assert.AreEqual(postInfo.Body, post.Body);
            Assert.AreEqual(postInfo.AuthorId, post.AuthorId);
            Assert.AreEqual(postInfo.SectionId, post.SectionId);
            Assert.AreEqual(postInfo.ParentId, post.ParentId);
            Assert.AreEqual(postInfo.RootId.Value, post.RootId);
        }
Пример #2
0
        private Guid CreateAccountId()
        {
            ResetWaiters();
            Guid?authorId = null;

            _commandService.Send(new CreateAccount {
                Name = RandomString(), Password = RandomString()
            }, (result) => {
                Assert.IsFalse(result.HasError);
                EventHandlerWaiter.WaitOne();
                authorId = AccountTest.AccountId;
                TestThreadWaiter.Set();
            });

            TestThreadWaiter.WaitOne(500);
            Assert.NotNull(authorId);
            return(authorId.Value);
        }
Пример #3
0
        public void ChangeSectionNameTest()
        {
            CreateSectionTest();
            Section section = null;

            ResetWaiters();
            var newSectionName = RandomString();

            _commandService.Send(new ChangeSectionName {
                SectionId = SectionId, SectionName = newSectionName
            }, (result) =>
            {
                Assert.IsFalse(result.HasError);
                EventHandlerWaiter.WaitOne();
                section = _memoryCache.Get <Section>(SectionId.ToString());
                TestThreadWaiter.Set();
            });
            TestThreadWaiter.WaitOne(500);
            Assert.AreEqual(newSectionName, section.Name);
        }
Пример #4
0
        public void ChangePostBodyTest()
        {
            CreateTopPostTest();

            ResetWaiters();
            var post = _memoryCache.Get <Post>(PostId.ToString());
            var body = RandomString();

            _commandService.Send(new ChangePostBody {
                PostId = PostId, Body = body
            }, (result) =>
            {
                Assert.IsFalse(result.HasError);
                EventHandlerWaiter.WaitOne();
                post = _memoryCache.Get <Post>(PostId.ToString());
                TestThreadWaiter.Set();
            });

            TestThreadWaiter.WaitOne(500);
            Assert.AreEqual(body, post.Body);
        }
Пример #5
0
        public void CreateAccountTest()
        {
            var name     = RandomString();
            var password = RandomString();

            ResetWaiters();
            Account account = null;

            _commandService.Send(new CreateAccount {
                Name = name, Password = password
            }, (result) =>
            {
                Assert.IsFalse(result.HasError);
                EventHandlerWaiter.WaitOne();
                account = _memoryCache.Get <Account>(AccountId.ToString());
                TestThreadWaiter.Set();
            });

            TestThreadWaiter.WaitOne(500);
            Assert.NotNull(account);
            Assert.AreEqual(name, account.Name);
            Assert.AreEqual(password, account.Password);
        }