chore: cleanup usings and run dotnet format
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
global using System.IO.Abstractions;
|
global using System.IO.Abstractions;
|
||||||
|
global using System.ServiceModel.Syndication;
|
||||||
|
global using System.Text;
|
||||||
global using System.Text.Json;
|
global using System.Text.Json;
|
||||||
|
global using System.Xml;
|
||||||
|
global using System.Xml.Linq;
|
||||||
|
|
||||||
global using Blog.Components;
|
global using Blog.Components;
|
||||||
global using Blog.Posts;
|
global using Blog.Posts;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class FilePostService(
|
|||||||
.UseAdvancedExtensions()
|
.UseAdvancedExtensions()
|
||||||
.UsePrism()
|
.UsePrism()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
private const string MetaFence = "meta";
|
private const string MetaFence = "meta";
|
||||||
private const string IndexFile = "index.md";
|
private const string IndexFile = "index.md";
|
||||||
|
|
||||||
@@ -68,12 +68,12 @@ class FilePostService(
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var indexFilePath = _fileSystem.Path.Combine(subDirectory, IndexFile);
|
var indexFilePath = _fileSystem.Path.Combine(subDirectory, IndexFile);
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(indexFilePath) is false)
|
if (_fileSystem.File.Exists(indexFilePath) is false)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var postText = await _fileSystem.File.ReadAllTextAsync(indexFilePath);
|
var postText = await _fileSystem.File.ReadAllTextAsync(indexFilePath);
|
||||||
|
|
||||||
var (metaContent, document) = ParsePost(postText);
|
var (metaContent, document) = ParsePost(postText);
|
||||||
@@ -108,7 +108,7 @@ class FilePostService(
|
|||||||
|
|
||||||
public async Task<PostWithContent?> GetPostAsync(string slug)
|
public async Task<PostWithContent?> GetPostAsync(string slug)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var postPath = _fileSystem.Path.Combine(_options.PostsDirectory, slug, IndexFile);
|
var postPath = _fileSystem.Path.Combine(_options.PostsDirectory, slug, IndexFile);
|
||||||
|
|
||||||
@@ -133,10 +133,10 @@ class FilePostService(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var postWithContent = post with
|
var postWithContent = post with
|
||||||
{
|
{
|
||||||
Slug = slug,
|
Slug = slug,
|
||||||
Content = document.ToHtml(MarkdownPipeline)
|
Content = document.ToHtml(MarkdownPipeline)
|
||||||
};
|
};
|
||||||
|
|
||||||
return postWithContent;
|
return postWithContent;
|
||||||
|
|||||||
+2
-7
@@ -1,8 +1,3 @@
|
|||||||
using System.ServiceModel.Syndication;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.ConfigureOptions<FilePostServiceOptionsSetup>();
|
builder.Services.ConfigureOptions<FilePostServiceOptionsSetup>();
|
||||||
@@ -29,11 +24,11 @@ app.UseAntiforgery();
|
|||||||
app.UseStatusCodePagesWithRedirects("/Error/{0}");
|
app.UseStatusCodePagesWithRedirects("/Error/{0}");
|
||||||
|
|
||||||
app
|
app
|
||||||
.MapGet("/rss", async (HttpContext context, IPostService postService) =>
|
.MapGet("/rss", async (HttpContext context, IPostService postService) =>
|
||||||
{
|
{
|
||||||
var req = context.Request;
|
var req = context.Request;
|
||||||
var url = $"{req.Scheme}://{req.Host}{req.PathBase}";
|
var url = $"{req.Scheme}://{req.Host}{req.PathBase}";
|
||||||
|
|
||||||
var posts = await postService.GetPostsAsync();
|
var posts = await postService.GetPostsAsync();
|
||||||
|
|
||||||
var items = posts.Select(post =>
|
var items = posts.Select(post =>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class BlogTest : PageTest
|
|||||||
{
|
{
|
||||||
await Context.Tracing.StopAsync(new()
|
await Context.Tracing.StopAsync(new()
|
||||||
{
|
{
|
||||||
Path = Path.Combine(
|
Path = Path.Combine(
|
||||||
TestContext.CurrentContext.WorkDirectory,
|
TestContext.CurrentContext.WorkDirectory,
|
||||||
"playwright-traces",
|
"playwright-traces",
|
||||||
$"{TestContext.CurrentContext.Test.ClassName}.{TestContext.CurrentContext.Test.Name}.zip"
|
$"{TestContext.CurrentContext.Test.ClassName}.{TestContext.CurrentContext.Test.Name}.zip"
|
||||||
|
|||||||
@@ -6,20 +6,20 @@ public class CompositeHost(IHost testHost, IHost kestrelHost) : IHost
|
|||||||
private readonly IHost _kestrelHost = kestrelHost;
|
private readonly IHost _kestrelHost = kestrelHost;
|
||||||
|
|
||||||
public IServiceProvider Services => _testHost.Services;
|
public IServiceProvider Services => _testHost.Services;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_testHost.Dispose();
|
_testHost.Dispose();
|
||||||
_kestrelHost.Dispose();
|
_kestrelHost.Dispose();
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken = default)
|
public async Task StartAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await _testHost.StartAsync(cancellationToken);
|
await _testHost.StartAsync(cancellationToken);
|
||||||
await _kestrelHost.StartAsync(cancellationToken);
|
await _kestrelHost.StartAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopAsync(CancellationToken cancellationToken = default)
|
public async Task StopAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await _testHost.StopAsync(cancellationToken);
|
await _testHost.StopAsync(cancellationToken);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Blog.Tests.EndToEnd;
|
namespace Blog.Tests.EndToEnd;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PostTests : BlogTest
|
public class PostTests : BlogTest
|
||||||
{
|
{
|
||||||
private const string TestPostSlug = "test-blog";
|
private const string TestPostSlug = "test-blog";
|
||||||
private const string TestPostTitle = "Test Blog";
|
private const string TestPostTitle = "Test Blog";
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
using System.ServiceModel.Syndication;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace Blog.Tests.EndToEnd;
|
namespace Blog.Tests.EndToEnd;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -15,9 +10,9 @@ public class RssTests : BlogTest
|
|||||||
response.Status.Should().Be((int)HttpStatusCode.OK);
|
response.Status.Should().Be((int)HttpStatusCode.OK);
|
||||||
|
|
||||||
var xml = await response.BodyAsync();
|
var xml = await response.BodyAsync();
|
||||||
|
|
||||||
var streamReader = new StreamReader(
|
var streamReader = new StreamReader(
|
||||||
new MemoryStream(xml),
|
new MemoryStream(xml),
|
||||||
Encoding.UTF8
|
Encoding.UTF8
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
global using System.IO.Abstractions;
|
global using System.IO.Abstractions;
|
||||||
global using System.Net;
|
global using System.Net;
|
||||||
|
global using System.ServiceModel.Syndication;
|
||||||
|
global using System.Text;
|
||||||
|
global using System.Xml;
|
||||||
|
|
||||||
global using Blog.Posts;
|
global using Blog.Posts;
|
||||||
|
|
||||||
@@ -10,10 +13,10 @@ global using Microsoft.AspNetCore.Hosting.Server;
|
|||||||
global using Microsoft.AspNetCore.Mvc.Testing;
|
global using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
global using Microsoft.Extensions.DependencyInjection;
|
global using Microsoft.Extensions.DependencyInjection;
|
||||||
global using Microsoft.Extensions.Hosting;
|
global using Microsoft.Extensions.Hosting;
|
||||||
|
global using Microsoft.Extensions.Logging;
|
||||||
global using Microsoft.Extensions.Options;
|
global using Microsoft.Extensions.Options;
|
||||||
global using Microsoft.Playwright;
|
global using Microsoft.Playwright;
|
||||||
global using Microsoft.Playwright.NUnit;
|
global using Microsoft.Playwright.NUnit;
|
||||||
global using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
global using Moq;
|
global using Moq;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class FilePostServiceTests
|
|||||||
.Returns(new FilePostServiceOptions { PostsDirectory = "posts" });
|
.Returns(new FilePostServiceOptions { PostsDirectory = "posts" });
|
||||||
|
|
||||||
_sut = new FilePostService(
|
_sut = new FilePostService(
|
||||||
_mockOptions.Object,
|
_mockOptions.Object,
|
||||||
_mockFileSystem.Object,
|
_mockFileSystem.Object,
|
||||||
_mockLogger.Object
|
_mockLogger.Object
|
||||||
);
|
);
|
||||||
@@ -326,8 +326,8 @@ class FilePostServiceTests
|
|||||||
_mockFileSystem
|
_mockFileSystem
|
||||||
.Setup(x => x.Directory.GetDirectories(It.IsAny<string>()))
|
.Setup(x => x.Directory.GetDirectories(It.IsAny<string>()))
|
||||||
.Returns([
|
.Returns([
|
||||||
"valid-blog-post",
|
"valid-blog-post",
|
||||||
"another-valid-blog-post",
|
"another-valid-blog-post",
|
||||||
"invalid-blog-post"
|
"invalid-blog-post"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user