Converting Tests back to C# but still with Playwright
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace IGP.Utils;
|
||||
|
||||
public static class Interval
|
||||
{
|
||||
public static string ToTime(int interval)
|
||||
{
|
||||
return TimeSpan.FromSeconds(interval).ToString(@"mm\:ss");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using Markdig;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace IGP.Utils;
|
||||
|
||||
public static class MarkdownFiles
|
||||
{
|
||||
private static readonly IDeserializer YamlDeserializer =
|
||||
new DeserializerBuilder()
|
||||
.IgnoreUnmatchedProperties()
|
||||
.Build();
|
||||
|
||||
public static readonly MarkdownPipeline Pipeline
|
||||
= new MarkdownPipelineBuilder()
|
||||
.UseYamlFrontMatter()
|
||||
.UseAdvancedExtensions()
|
||||
.Build();
|
||||
|
||||
public static async Task<string> LoadMarkdown(HttpClient httpClient, string filepath)
|
||||
{
|
||||
return await httpClient.GetStringAsync(filepath);
|
||||
}
|
||||
|
||||
public static async Task<T> LoadFrontMatter<T>(HttpClient httpClient, string filepath)
|
||||
{
|
||||
var markdown = await LoadMarkdown(httpClient, filepath);
|
||||
|
||||
var document = Markdown.Parse(markdown, Pipeline);
|
||||
|
||||
var block = document
|
||||
.Descendants<YamlFrontMatterBlock>()
|
||||
.FirstOrDefault();
|
||||
|
||||
if (block == null)
|
||||
return default!;
|
||||
|
||||
var yaml =
|
||||
block
|
||||
.Lines
|
||||
.Lines
|
||||
.OrderByDescending(x => x.Line)
|
||||
.Select(x => $"{x}\n")
|
||||
.ToList()
|
||||
.Select(x => x.Replace("---", string.Empty))
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Aggregate((s, agg) => agg + s);
|
||||
|
||||
return YamlDeserializer.Deserialize<T>(yaml);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace IGP.Utils;
|
||||
|
||||
public static class Project
|
||||
{
|
||||
public static string GitResourcesUrl =>
|
||||
"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference/blob/develop/IGP/wwwroot/";
|
||||
}
|
||||
Reference in New Issue
Block a user