Example #1
0
        public void Should_Convert_Comment_Text_To_String()
        {
            var    text = "this is my text";
            string sut  = CommentText.Create(text).Value;

            sut.Should().Be(text);
        }
Example #2
0
        public async Task Should_Load_All_Details_For_A_Post()
        {
            PostModel result;
            var       author  = new User((Nickname)"author7", (FullName)"author seven", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var       reader  = new User((Nickname)"reader1", (FullName)"reader one", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var       post    = new Post(author, (Picture)Convert.FromBase64String(DatabaseFixture.GetTestPictureBase64()), (PostText)"test post");
            var       comment = new Comment(post, reader, CommentText.Create("My comment").Value);

            using (var session = _testFixture.OpenSession(_output))
            {
                post.AddComment(comment);
                post.PutLikeBy(reader);
                await session.SaveAsync(reader);

                await session.SaveAsync(author);

                await session.SaveAsync(post);
            }

            var query = new PostDetailQuery(post.ID, reader.ID);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new PostDetailQueryHandler(session, Log.Logger);
                result = await sut.Handle(query, default);
            }

            using (new AssertionScope())
            {
                result.Should().NotBeNull();
                result.LikesCount.Should().Be(1);
                result.Comments.Length.Should().Be(1);
                result.IsLikedByCurrentUser.Should().BeTrue();
            }
        }
Example #3
0
        public async Task Should_Find_One_Comment_For_Post()
        {
            CommentModel[] comments;
            var            author  = new User((Nickname)"author7", (FullName)"author seven", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var            post    = new Post(author, (Picture)Convert.FromBase64String(DatabaseFixture.GetTestPictureBase64()), (PostText)"test post");
            var            comment = new Comment(post, author, CommentText.Create("First comment").Value);

            using (var session = _testFixture.OpenSession(_output))
            {
                post.AddComment(comment);
                await session.SaveAsync(author);

                await session.SaveAsync(post);
            }

            var query = new PostCommentsQuery(post.ID);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new PostCommentsQueryHandler(session, Log.Logger);
                comments = await sut.Handle(query, default);
            }

            comments.Length.Should().Be(1);
        }
Example #4
0
        public void Different_Strings_Should_Create_Different_Comment_Texts()
        {
            var text1 = CommentText.Create("this is my text").Value;
            var text2 = CommentText.Create("this is my other text").Value;

            using (new AssertionScope())
            {
                text1.Should().NotBe(text2);
                text1.GetHashCode().Equals(text2.GetHashCode()).Should().BeFalse();
            }
        }
Example #5
0
        public void Same_String_Should_Create_The_Same_Comment_Text()
        {
            var text1 = CommentText.Create("this is my text").Value;
            var text2 = CommentText.Create("this is my text").Value;

            using (new AssertionScope())
            {
                text1.Should().Be(text2);
                text1.GetHashCode().Equals(text2.GetHashCode()).Should().BeTrue();
            }
        }
Example #6
0
        public void Comment_Text_From_String_Too_Long_Is_Not_Valid()
        {
            var sut = new string('x', 1000);

            CommentText.Create(sut).IsFailure.Should().BeTrue();
        }
Example #7
0
 public void Empty_Comment_Text_Is_Not_Valid()
 {
     CommentText.Create(string.Empty).IsFailure.Should().BeTrue();
 }
Example #8
0
 public void Should_Create_A_Valid_Text_For_A_Comment()
 {
     CommentText.Create("this is my text").IsSuccess.Should().BeTrue();
 }