[tests] Apply formatting rules
This commit is contained in:
parent
50d3068a57
commit
94b7eb7c66
2 changed files with 27 additions and 26 deletions
|
@ -18,12 +18,12 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3"/>
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.4.3"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -66,7 +66,8 @@ public class MfmTests
|
|||
[TestMethod]
|
||||
public void TestMention()
|
||||
{
|
||||
const string input = "test @test test @test@instance.tld @test_ @_test @test_@ins-tance.tld @_test@xn--mastodn-f1a.de @_test@-xn--mastodn-f1a.de";
|
||||
const string input =
|
||||
"test @test test @test@instance.tld @test_ @_test @test_@ins-tance.tld @_test@xn--mastodn-f1a.de @_test@-xn--mastodn-f1a.de";
|
||||
List<MfmNode> expected =
|
||||
[
|
||||
new MfmTextNode("test "),
|
||||
|
@ -81,7 +82,7 @@ public class MfmTests
|
|||
new MfmMentionNode("test_@ins-tance.tld", "test_", "ins-tance.tld"),
|
||||
new MfmTextNode(" "),
|
||||
new MfmMentionNode("_test@xn--mastodn-f1a.de", "_test", "xn--mastodn-f1a.de"),
|
||||
new MfmTextNode(" @_test@-xn--mastodn-f1a.de"),
|
||||
new MfmTextNode(" @_test@-xn--mastodn-f1a.de")
|
||||
];
|
||||
var res = Mfm.parse(input);
|
||||
|
||||
|
@ -180,7 +181,7 @@ public class MfmTests
|
|||
new MfmHashtagNode("test"),
|
||||
new MfmTextNode("'s "),
|
||||
new MfmHashtagNode("t-e_s-t"),
|
||||
new MfmTextNode(". test"),
|
||||
new MfmTextNode(". test")
|
||||
];
|
||||
var res = Mfm.parse(input);
|
||||
|
||||
|
@ -226,30 +227,13 @@ public class MfmTests
|
|||
}
|
||||
}
|
||||
|
||||
private class MfmNodeEquality : IEqualityComparer<MfmNode>
|
||||
{
|
||||
public bool Equals(MfmNode? x, MfmNode? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null && y != null) return false;
|
||||
if (x != null && y == null) return false;
|
||||
|
||||
return MfmNodeEqual(x!, y!);
|
||||
}
|
||||
|
||||
public int GetHashCode(MfmNode obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool MfmNodeEqual(MfmNode a, MfmNode b)
|
||||
{
|
||||
if (a.GetType() != b.GetType()) return false;
|
||||
|
||||
if (!a.Children.IsEmpty || !b.Children.IsEmpty)
|
||||
{
|
||||
if (!a.Children.IsEmpty && b.Children.IsEmpty || a.Children.IsEmpty && !b.Children.IsEmpty)
|
||||
if ((!a.Children.IsEmpty && b.Children.IsEmpty) || (a.Children.IsEmpty && !b.Children.IsEmpty))
|
||||
return false;
|
||||
if (!a.Children.SequenceEqual(b.Children, new MfmNodeEquality()))
|
||||
return false;
|
||||
|
@ -338,4 +322,21 @@ public class MfmTests
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class MfmNodeEquality : IEqualityComparer<MfmNode>
|
||||
{
|
||||
public bool Equals(MfmNode? x, MfmNode? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null && y != null) return false;
|
||||
if (x != null && y == null) return false;
|
||||
|
||||
return MfmNodeEqual(x!, y!);
|
||||
}
|
||||
|
||||
public int GetHashCode(MfmNode obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue