-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change overrides to be passed via source file
Decided that passing via json in the settings file was too obtuse tag: Changed version: 0.7.0
- Loading branch information
Ben Zumhagen
committed
Nov 13, 2019
1 parent
55cf6fa
commit 4f7e665
Showing
19 changed files
with
464 additions
and
184 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
75 changes: 75 additions & 0 deletions
75
dotnet-gitchanges.Tests/Readers/Parsers/FileSourceRowParserTests.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,75 @@ | ||
using System; | ||
using System.IO; | ||
using Gitchanges.Changes; | ||
using Gitchanges.Readers.Parsers; | ||
using NUnit.Framework; | ||
|
||
namespace Gitchanges.Tests.Readers.Parsers | ||
{ | ||
[TestFixture] | ||
public class FileSourceRowParserTests | ||
{ | ||
[Test] | ||
public void VerifyParserParsesLineWithReferenceSuccessfully() | ||
{ | ||
var expectedChange = new GitChange("0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date, "Some Reference"); | ||
var line = $"{expectedChange.Reference}|{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new FileSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.EqualTo(expectedChange)); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserParsesLineWithoutReferenceSuccessfully() | ||
{ | ||
var expectedChange = new GitChange("0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new FileSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.EqualTo(expectedChange)); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesTooFewDelimitersIssues() | ||
{ | ||
var expectedChange = new GitChange("0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Version}{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new FileSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Wrong number of values. Expected 4 or 5 but was 3")); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesTooManyDelimiterIssues() | ||
{ | ||
var expectedChange = new GitChange("0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Version}|||{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new FileSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Wrong number of values. Expected 4 or 5 but was 6")); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesDateFormatIssues() | ||
{ | ||
var expectedChange = new GitChange("0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date}"; | ||
var writer = new StringWriter(); | ||
var parser = new FileSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Date should match the format 'yyyy-MM-dd'")); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
dotnet-gitchanges.Tests/Readers/Parsers/OverrideSourceRowParserTests.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,75 @@ | ||
using System; | ||
using System.IO; | ||
using Gitchanges.Changes; | ||
using Gitchanges.Readers.Parsers; | ||
using NUnit.Framework; | ||
|
||
namespace Gitchanges.Tests.Readers.Parsers | ||
{ | ||
[TestFixture] | ||
public class OverrideSourceRowParserTests | ||
{ | ||
[Test] | ||
public void VerifyParserParsesLineWithReferenceSuccessfully() | ||
{ | ||
var expectedChange = new OverrideChange("123456", "0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date, "Some Reference"); | ||
var line = $"{expectedChange.Id}|{expectedChange.Reference}|{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new OverrideSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.EqualTo(expectedChange)); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserParsesLineWithoutReferenceSuccessfully() | ||
{ | ||
var expectedChange = new OverrideChange("123456", "0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Id}|{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new OverrideSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.EqualTo(expectedChange)); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesTooFewDelimitersIssues() | ||
{ | ||
var expectedChange = new OverrideChange("123456", "0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Id}|{expectedChange.Version}{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new OverrideSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Wrong number of values. Expected 5 or 6 but was 4")); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesTooManyDelimitersIssues() | ||
{ | ||
var expectedChange = new OverrideChange("123456", "0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Id}|||{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date:yyyy-MM-dd}"; | ||
var writer = new StringWriter(); | ||
var parser = new OverrideSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Wrong number of values. Expected 5 or 6 but was 7")); | ||
} | ||
|
||
[Test] | ||
public void VerifyParserHandlesDateFormatIssues() | ||
{ | ||
var expectedChange = new OverrideChange("123456", "0.1.0", "Some Tag", "Some Summary", DateTimeOffset.Now.Date); | ||
var line = $"{expectedChange.Id}|{expectedChange.Version}|{expectedChange.Tag}|{expectedChange.Summary}|{expectedChange.Date}"; | ||
var writer = new StringWriter(); | ||
var parser = new OverrideSourceRowParser(writer); | ||
var actual = parser.Parse(line); | ||
|
||
Assert.That(actual, Is.Null); | ||
Assert.That(writer.ToString().Trim(), Is.EqualTo($"Error parsing line '{line}'. Date should match the format 'yyyy-MM-dd'")); | ||
} | ||
} | ||
} |
Oops, something went wrong.