Skip to content

Commit

Permalink
And more issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Jul 26, 2023
1 parent b8d3ad2 commit a0c5c5d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Src/CSharpier.VSCode/.idea/prettier.xml

.idea/.idea.CSharpier/.idea/riderMarkupCache.xml
/Src/CSharpier.Benchmarks/BenchmarkDotNet.Artifacts/
/Src/CSharpier.Tests/TestResults
5 changes: 5 additions & 0 deletions Src/CSharpier.Tests/DocPrinterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ private static void PrintedDocShouldBe(
bool useTabs = false
)
{
if (Environment.GetEnvironmentVariable("NormalizeLineEndings") != null)
{
expected = expected.Replace("\r\n", "\n");
}

var result = Print(doc, width, trimInitialLines, useTabs);

result.Should().Be(expected);
Expand Down
106 changes: 53 additions & 53 deletions Src/CSharpier.Tests/DocSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Should_Format_Directive()

var actual = DocSerializer.Serialize(doc);

actual.Should().Be("Doc.Directive(\"1\")");
ActualShouldBe(actual, "Doc.Directive(\"1\")");
}

[Test]
Expand All @@ -37,10 +37,9 @@ public void Should_Format_Basic_Types()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.Concat(
ActualShouldBe(
actual,
@"Doc.Concat(
Doc.Line,
Doc.LiteralLine,
Doc.HardLine,
Expand All @@ -53,7 +52,7 @@ public void Should_Format_Basic_Types()
Doc.BreakParent,
""1""
)"
);
);
}

[Test]
Expand All @@ -63,14 +62,13 @@ public void Should_Print_Basic_Group()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.Group(
ActualShouldBe(
actual,
@"Doc.Group(
Doc.Null,
Doc.Null
)"
);
);
}

[Test]
Expand All @@ -80,15 +78,14 @@ public void Should_Print_Group_With_Id()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.GroupWithId(
ActualShouldBe(
actual,
@"Doc.GroupWithId(
""1"",
Doc.Null,
Doc.Null
)"
);
);
}

[Test]
Expand All @@ -101,10 +98,9 @@ public void Should_Print_ConditionalGroup()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.ConditionalGroup(
ActualShouldBe(
actual,
@"Doc.ConditionalGroup(
Doc.Concat(
Doc.Line,
Doc.Line
Expand All @@ -114,7 +110,7 @@ public void Should_Print_ConditionalGroup()
Doc.LiteralLine
)
)"
);
);
}

[Test]
Expand All @@ -124,15 +120,14 @@ public void Should_Print_Align()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.Align(
ActualShouldBe(
actual,
@"Doc.Align(
2,
Doc.Null,
Doc.Null
)"
);
);
}

[Test]
Expand All @@ -142,14 +137,13 @@ public void Should_Print_ForceFlat()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.ForceFlat(
ActualShouldBe(
actual,
@"Doc.ForceFlat(
Doc.Null,
Doc.Null
)"
);
);
}

[Test]
Expand All @@ -159,14 +153,13 @@ public void Should_Print_Indent()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.Indent(
ActualShouldBe(
actual,
@"Doc.Indent(
Doc.Null,
Doc.Null
)"
);
);
}

[Test]
Expand All @@ -176,14 +169,13 @@ public void Should_Print_IndentIfBreak()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.IndentIfBreak(
ActualShouldBe(
actual,
@"Doc.IndentIfBreak(
Doc.Null,
""1""
)"
);
);
}

[Test]
Expand All @@ -193,15 +185,14 @@ public void Should_Print_IfBreak_With_Id()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.IfBreak(
ActualShouldBe(
actual,
@"Doc.IfBreak(
Doc.Null,
Doc.Line,
""1""
)"
);
);
}

[Test]
Expand All @@ -211,14 +202,13 @@ public void Should_Print_IfBreak_Without_Id()

var actual = DocSerializer.Serialize(doc);

actual
.Should()
.Be(
@"Doc.IfBreak(
ActualShouldBe(
actual,
@"Doc.IfBreak(
Doc.Null,
Doc.Line
)"
);
);
}

[TestCase(CommentType.SingleLine)]
Expand All @@ -229,7 +219,7 @@ public void Should_Print_LeadingComment(CommentType commentType)

var actual = DocSerializer.Serialize(doc);

actual.Should().Be(@$"Doc.LeadingComment(""1"", CommentType.{commentType})");
ActualShouldBe(actual, @$"Doc.LeadingComment(""1"", CommentType.{commentType})");
}

[TestCase(CommentType.SingleLine)]
Expand All @@ -240,6 +230,16 @@ public void Should_Print_TrailingComment(CommentType commentType)

var actual = DocSerializer.Serialize(doc);

actual.Should().Be(@$"Doc.TrailingComment(""1"", CommentType.{commentType})");
ActualShouldBe(actual, @$"Doc.TrailingComment(""1"", CommentType.{commentType})");
}

private static void ActualShouldBe(string result, string be)
{
if (Environment.GetEnvironmentVariable("NormalizeLineEndings") != null)
{
be = be.Replace("\r\n", "\n");
}

result.Should().Be(be);
}
}
26 changes: 13 additions & 13 deletions Src/CSharpier.Tests/OptionsProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public async Task Should_Support_EditorConfig_Basic()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_style = space
Expand All @@ -219,7 +219,7 @@ public async Task Should_Support_EditorConfig_Tabs(string propertyName)
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
$@"
[*]
indent_style = tab
Expand All @@ -238,7 +238,7 @@ public async Task Should_Support_EditorConfig_Tabs_With_Tab_Width()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_style = tab
Expand All @@ -258,7 +258,7 @@ public async Task Should_Support_EditorConfig_Tabs_With_Indent_Size_Tab()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_size = tab
Expand All @@ -276,15 +276,15 @@ public async Task Should_Support_EditorConfig_Tabs_With_Multiple_Files()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/subfolder/.editorConfig",
"c:/test/subfolder/.editorconfig",
@"
[*]
indent_size = 1
"
);

context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_size = 2
Expand All @@ -305,15 +305,15 @@ public async Task Should_Support_EditorConfig_Tabs_With_Multiple_Files_And_Unset
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/subfolder/.editorConfig",
"c:/test/subfolder/.editorconfig",
@"
[*]
indent_size = unset
"
);

context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_size = 2
Expand All @@ -332,7 +332,7 @@ public async Task Should_Support_EditorConfig_Tabs_With_Globs()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*]
indent_size = 1
Expand All @@ -351,7 +351,7 @@ public async Task Should_Find_EditorConfig_In_Parent_Directory()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*.cs]
indent_size = 2
Expand All @@ -370,7 +370,7 @@ public async Task Should_Prefer_CSharpierrc_In_SameFolder()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*.cs]
indent_size = 2
Expand All @@ -390,7 +390,7 @@ public async Task Should_Prefer_Closer_EditorConfig()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/subfolder/.editorConfig",
"c:/test/subfolder/.editorconfig",
@"
[*.cs]
indent_size = 2
Expand All @@ -410,7 +410,7 @@ public async Task Should_Prefer_Closer_CSharpierrc()
{
var context = new TestContext();
context.WhenAFileExists(
"c:/test/.editorConfig",
"c:/test/.editorconfig",
@"
[*.cs]
indent_size = 2
Expand Down
Loading

0 comments on commit a0c5c5d

Please sign in to comment.