-
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.
New argument added for customizing end-of-line characters in output f…
…iles (#6) * Initial commit (#1) * Initial commit * Names refactoring * Readme.md and license provided, fixed pipelines, usage examples, minor fixes, cleaning code * Update README.md * Transient vulnerabilities removed. Cleaning code. * Tool version updated in examples * Another enhancement to control end-of-line in created file * fix: End-of-lines in YAML serialization * Readme file updated --------- Co-authored-by: Paweł Jankowski <[email protected]>
- Loading branch information
1 parent
cb96ef3
commit 340b7af
Showing
12 changed files
with
99 additions
and
16 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
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
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); | ||
} | ||
} |