Example #1
0
        public async Task Create_should_create_events()
        {
            var command = new CreateComment {
                Text = "text1", Url = new Uri("http://uri")
            };

            var result = await sut.ExecuteAsync(CreateCommentsCommand(command));

            result.ShouldBeEquivalent((object)EntityCreatedResult.Create(command.CommentId, 0));

            sut.GetCommentsAsync(0).Result.Should().BeEquivalentTo(new CommentsResult {
                Version = 0
            });
            sut.GetCommentsAsync(-1).Result.Should().BeEquivalentTo(new CommentsResult
            {
                CreatedComments = new List <Comment>
                {
                    new Comment(command.CommentId, GetTime(), command.Actor, "text1", command.Url)
                },
                Version = 0
            });

            LastEvents
            .ShouldHaveSameEvents(
                CreateCommentsEvent(new CommentCreated {
                Text = command.Text, Url = command.Url
            })
                );
        }
        public async Task Create_should_create_events()
        {
            var command = new CreateComment {
                Text = "text1"
            };

            var result = await sut.ExecuteAsync(CreateCommentsCommand(command));

            result.ShouldBeEquivalent(EntityCreatedResult.Create(command.CommentId, 0));

            sut.GetCommentsAsync(0).Result.Should().BeEquivalentTo(new CommentsResult {
                Version = 0
            });
            sut.GetCommentsAsync(-1).Result.Should().BeEquivalentTo(new CommentsResult
            {
                CreatedComments = new List <Comment>
                {
                    new Comment(command.CommentId, LastEvents.ElementAt(0).Headers.Timestamp(), command.Actor, "text1")
                },
                Version = 0
            });

            LastEvents
            .ShouldHaveSameEvents(
                CreateCommentsEvent(new CommentCreated {
                CommentId = command.CommentId, Text = command.Text
            })
                );
        }