Beispiel #1
0
        // Get one blogs with n comments
        public async Task <Benchmark> BenchmarkGettingBlogWithSomeComments(string referenceBlogId, string embeddedBlogId, int numberOfComments)
        {
            var benchmark    = new Benchmark(BenchmarkType.GetOneBlogWithSomeComments);
            var embeddedBlog = await this._embeddedOperations.GetOneBlogWithSomeComments(embeddedBlogId);

            benchmark.BenchmarkResults.Add(new BenchmarkResult {
                EmbeddedBlogResponse = embeddedBlog
            });

            var result = await this._referentialOperations.GetOneBlogWithSomeComments(referenceBlogId, numberOfComments);

            var blogResponse     = result.Item1;
            var commentResponses = result.Item2;
            var referentialBlogBenchmarkResult = new BenchmarkResult
            {
                ReferentialBlogResponse = blogResponse,
                ChildBenchmarkResults   = commentResponses.Select(c => new BenchmarkResult {
                    ReferentialCommentResponse = c
                }).ToList()
            };

            benchmark.AddResult(referentialBlogBenchmarkResult);

            return(benchmark);
        }
Beispiel #2
0
        // Update n comments
        public async Task <Benchmark> BenchmarkUpdatingComments(string referenceBlogId, string embeddedBlogId, int commentsCount)
        {
            // TODO.
            var benchmark    = new Benchmark(BenchmarkType.UpdateAllCommentsInABlog);
            var embeddedBlog = await this._embeddedOperations.GetBlog(embeddedBlogId);

            benchmark.BenchmarkResults.Add(new BenchmarkResult {
                EmbeddedBlogResponse = embeddedBlog
            });
            var comments = _blogGenerator.GenrateBlogComments(commentsCount, embeddedBlog.Item.Comments[0].CommentText.Length);

            for (int i = 0; i < commentsCount; i++)
            {
                embeddedBlog.Item.BlogComments[i].CommentText = comments[i].CommentText;
                embeddedBlog.Item.BlogComments[i].CommentedOn = DateTime.UtcNow;
            }

            var response = await this._embeddedOperations.UpdateBlog(embeddedBlog.Item);

            benchmark.BenchmarkResults.Add(new BenchmarkResult {
                EmbeddedBlogResponse = response
            });

            var result = await this._referentialOperations.GetOneBlogWithAllComments(referenceBlogId);

            var refernceBlog      = result.Item1;
            var referenceComments = result.Item2;

            var referenceBlogBenchmarkResult = new BenchmarkResult {
                ReferentialBlogResponse = refernceBlog
            };

            var referenceCommentsGenerated = _blogGenerator.GenrateBlogComments(commentsCount, referenceComments[0].Item.CommentText.Length);

            for (int i = 0; i < commentsCount; i++)
            {
                referenceComments[i].Item.CommentText = referenceCommentsGenerated[i].CommentText;
                referenceComments[i].Item.CommentedOn = DateTime.UtcNow;
                var updateResponse = await this._referentialOperations.UpdateComment(referenceComments[i].Item);

                referenceBlogBenchmarkResult.ChildBenchmarkResults.Add(new BenchmarkResult {
                    ReferentialCommentResponse = updateResponse, CommentGenerationResult = referenceCommentsGenerated[i]
                });
            }

            benchmark.AddResult(referenceBlogBenchmarkResult);

            return(benchmark);
        }