public async Task Handler_Should_UpdateBlogSettings()
        {
            var existingBlogSettings = new BlogSettings
            {
                Title        = "blog title-UPDATED",
                Description  = "blog description-UPDATED",
                CoverCaption = "blog cover caption-UPDATED",
                CoverLink    = "blog cover link-UPDATED",
                CoverUrl     = "blog cover url-UPDATED",
                Created      = DateTime.UtcNow,
            };

            BlogSettings resultBlogSettings = null;

            BlogSettingsRepositoryMock.Setup(m => m.SingleOrDefaultAsync(It.IsAny <CancellationToken>())).ReturnsAsync(existingBlogSettings);
            BlogSettingsRepositoryMock.Setup(m => m.Update(It.IsAny <BlogSettings>())).Callback((BlogSettings bs) => resultBlogSettings = bs);

            var result = await Mediator.Send(new UpdateBlogSettingsCommand
            {
                Title        = "blog title-UPDATED",
                Description  = "blog description-UPDATED",
                CoverCaption = "blog cover caption-UPDATED",
                CoverLink    = "blog cover link-UPDATED",
                CoverUrl     = "blog cover url-UPDATED"
            });

            result.IsSuccess.Should().BeTrue();

            resultBlogSettings.Should().NotBeNull();
            resultBlogSettings.Title.Should().Be("blog title-UPDATED");
            resultBlogSettings.Description.Should().Be("blog description-UPDATED");
            resultBlogSettings.CoverCaption.Should().Be("blog cover caption-UPDATED");
            resultBlogSettings.CoverLink.Should().Be("blog cover link-UPDATED");
            resultBlogSettings.CoverUrl.Should().Be("blog cover url-UPDATED");
        }
        public async Task Handler_Should_CoverUrl_ReplaceBaseUrlWithUrlFormat()
        {
            BlogSettings resultBlogSettings = null;

            BlogSettingsRepositoryMock.Setup(m => m.SingleOrDefaultAsync(It.IsAny <CancellationToken>())).ReturnsAsync(default(BlogSettings));
            BlogSettingsRepositoryMock.Setup(m => m.Add(It.IsAny <BlogSettings>())).Callback((BlogSettings bs) => resultBlogSettings = bs);

            var result = await Mediator.Send(new UpdateBlogSettingsCommand
            {
                Title    = "blog title-NEW",
                CoverUrl = "http://127.0.0.1:10000/devstoreaccount1/pineblog-tests/blog-cover-url"
            });

            result.IsSuccess.Should().BeTrue();

            resultBlogSettings.Should().NotBeNull();
            resultBlogSettings.CoverUrl.Should().Be("%URL%/blog-cover-url");
        }
        public async Task Handler_Should_AddSettings_WhenNotFound()
        {
            BlogSettings resultBlogSettings = null;

            BlogSettingsRepositoryMock.Setup(m => m.SingleOrDefaultAsync(It.IsAny <CancellationToken>())).ReturnsAsync(default(BlogSettings));
            BlogSettingsRepositoryMock.Setup(m => m.Add(It.IsAny <BlogSettings>())).Callback((BlogSettings bs) => resultBlogSettings = bs);

            var result = await Mediator.Send(new UpdateBlogSettingsCommand
            {
                Title = "blog title-NEW"
            });

            result.IsSuccess.Should().BeTrue();

            BlogSettingsRepositoryMock.Verify(m => m.Add(It.IsAny <BlogSettings>()), Times.Once);
            BlogSettingsRepositoryMock.Verify(m => m.Update(It.IsAny <BlogSettings>()), Times.Never);

            resultBlogSettings.Should().NotBeNull();
            resultBlogSettings.Title.Should().Be("blog title-NEW");
        }