-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another enhancement to control end-of-line in created file
- Loading branch information
1 parent
c4109f2
commit 74c8e6e
Showing
6 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/UnitTests/Repository/JsonConfigurationRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Text; | ||
using Antyrama.Tools.Scribe.Core; | ||
using Antyrama.Tools.Scribe.Core.Repository; | ||
using FluentAssertions; | ||
|
||
namespace UnitTests.Repository; | ||
|
||
public sealed class JsonConfigurationRepositoryTests | ||
{ | ||
[Theory] | ||
[InlineData(EndOfLine.CrLf, "\r\n")] | ||
[InlineData(EndOfLine.Cr, "\r")] | ||
[InlineData(EndOfLine.Lf, "\n")] | ||
public void ShouldWriteAndReadConfigFileWithAllPossibleEndOfLines(EndOfLine? eol, string eolChars) | ||
{ | ||
// arrange | ||
var options = new ToolInternalOptions { Eol = eol }; | ||
var sut = new JsonConfigurationRepository(options); | ||
|
||
using var stream = new MemoryStream(); | ||
|
||
// act | ||
sut.Save(stream, | ||
new IReadOnlyDictionary<string, object>[] | ||
{ | ||
new Dictionary<string, object> { { "key1", "value1" }, { "key2", "value2" } } | ||
}); | ||
|
||
// assert | ||
stream.Seek(0, SeekOrigin.Begin); | ||
|
||
using var reader = new StreamReader(stream, Encoding.UTF8); | ||
var result = reader.ReadToEnd(); | ||
|
||
result.Should().Contain(eolChars); | ||
} | ||
} |