Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codito committed Dec 23, 2023
1 parent f15115e commit 7b5cded
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/Noted/Core/Models/EpubXPathLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Noted.Core.Models;
using System;
using System.Text.RegularExpressions;

public struct EpubXPathLocation(string pos0, string pos1) : IComparable
public readonly struct EpubXPathLocation(string pos0, string pos1) : IComparable
{
public EpubLocation Start { get; init; } = EpubLocation.FromString(pos0);

Expand All @@ -18,9 +18,9 @@ public static EpubXPathLocation FromString(string location)
return new EpubXPathLocation(range[0], range[1]);
}

public override string ToString() => $"epubxpath://{this.Start}-{this.End}";
public override readonly string ToString() => $"epubxpath://{this.Start}-{this.End}";

public int CompareTo(object? obj)
public readonly int CompareTo(object? obj)
{
if (obj is not EpubXPathLocation other)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

namespace Noted.Tests.Extensions.Readers.Common
{
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Noted.Extensions.Readers.Common;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Noted.Extensions.Readers.Common;

[TestClass]
public class HtmlSectionParserTests
{
private const string TocFragment = @"
[TestClass]
public class HtmlSectionParserTests
{
private const string TocFragment = @"
<p height=""1em"" width=""0pt"" align=""center"">
<font size=""5"">
<b>Table of Contents</b>
Expand Down Expand Up @@ -59,44 +59,44 @@ public class HtmlSectionParserTests
<mbp:pagebreak/>
";

private readonly HtmlSectionParser parser;
private readonly HtmlSectionParser parser;

public HtmlSectionParserTests()
{
this.parser = new HtmlSectionParser();
}
public HtmlSectionParserTests()
{
this.parser = new HtmlSectionParser();
}

[TestMethod]
public async Task ParseShouldReturnTableOfContentWithDepth()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
var toc = await HtmlSectionParser.Parse(stream).ToListAsync();
[TestMethod]
public async Task ParseShouldReturnTableOfContentWithDepth()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
var toc = await HtmlSectionParser.Parse(stream).ToListAsync();

Assert.AreEqual(11, toc.Count);
Assert.AreEqual("Preface", toc[0].Title);
Assert.AreEqual(1, toc[0].Level);
Assert.AreEqual(3859, toc[0].Location);
Assert.AreEqual("Section 1.1", toc[4].Title);
Assert.AreEqual(2, toc[4].Level);
Assert.AreEqual(21076, toc[4].Location);
Assert.AreEqual("Section 1.1.1", toc[5].Title);
Assert.AreEqual(3, toc[5].Level);
Assert.AreEqual("Section 1.2", toc[6].Title);
Assert.AreEqual(2, toc[6].Level);
}
Assert.AreEqual(11, toc.Count);
Assert.AreEqual("Preface", toc[0].Title);
Assert.AreEqual(1, toc[0].Level);
Assert.AreEqual(3859, toc[0].Location);
Assert.AreEqual("Section 1.1", toc[4].Title);
Assert.AreEqual(2, toc[4].Level);
Assert.AreEqual(21076, toc[4].Location);
Assert.AreEqual("Section 1.1.1", toc[5].Title);
Assert.AreEqual(3, toc[5].Level);
Assert.AreEqual("Section 1.2", toc[6].Title);
Assert.AreEqual(2, toc[6].Level);
}

[TestMethod]
public async Task ParseShouldCreateDocumentSectionRelationships()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
var toc = await HtmlSectionParser.Parse(stream).ToListAsync();
[TestMethod]
public async Task ParseShouldCreateDocumentSectionRelationships()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
var toc = await HtmlSectionParser.Parse(stream).ToListAsync();

Assert.AreEqual(null, toc[3].Parent); // 1 -> null
Assert.AreEqual("Section 1.1", toc[4].Title);
Assert.AreEqual(toc[3], toc[4].Parent); // 1.1 -> 1
Assert.AreEqual(toc[4], toc[5].Parent); // 1.1.1 -> 1.1
Assert.AreEqual(toc[3], toc[6].Parent); // 1.2 -> 1
Assert.AreEqual(null, toc[7].Parent); // 2 -> null
Assert.AreEqual(null, toc[3].Parent); // 1 -> null
Assert.AreEqual("Section 1.1", toc[4].Title);
Assert.AreEqual(toc[3], toc[4].Parent); // 1.1 -> 1
Assert.AreEqual(toc[4], toc[5].Parent); // 1.1.1 -> 1.1
Assert.AreEqual(toc[3], toc[6].Parent); // 1.2 -> 1
Assert.AreEqual(null, toc[7].Parent); // 2 -> null
}
}
}
}

0 comments on commit 7b5cded

Please sign in to comment.