-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f81357
commit edab6d3
Showing
5 changed files
with
82 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using FluentAssertions; | ||
using RecordParser.Engines.Reader; | ||
using System; | ||
using Xunit; | ||
|
||
namespace RecordParser.Test | ||
{ | ||
public class TextFindHelperTest : TestSetup | ||
{ | ||
[Fact] | ||
public void Given_column_mapped_more_than_once_should_works() | ||
{ | ||
var id = Guid.NewGuid().ToString(); | ||
var date = "2020.05.23"; | ||
var color = "LightBlue"; | ||
|
||
var record = $"{id};{date};{color}"; | ||
var finder = new TextFindHelper(record, ";", ('"', "\"")); | ||
; | ||
// Act | ||
|
||
var a = finder.GetValue(0); | ||
var b = finder.GetValue(0); | ||
var c = finder.GetValue(1); | ||
var d = finder.GetValue(2); | ||
var e = finder.GetValue(2); | ||
|
||
// Assert | ||
|
||
a.Should().Be(id); | ||
b.Should().Be(id); | ||
c.Should().Be(date); | ||
d.Should().Be(color); | ||
e.Should().Be(color); | ||
} | ||
|
||
[Fact] | ||
public void Given_access_to_past_column_should_throw() | ||
{ | ||
var id = Guid.NewGuid().ToString(); | ||
var date = "2020.05.23"; | ||
var color = "LightBlue"; | ||
|
||
var record = $"{id};{date};{color}"; | ||
|
||
string a, b, c, d; | ||
a = b = c = d = null; | ||
|
||
// Act | ||
|
||
var action = () => | ||
{ | ||
var finder = new TextFindHelper(record, ";", ('"', "\"")); | ||
|
||
a = finder.GetValue(0).ToString(); | ||
b = finder.GetValue(1).ToString(); | ||
c = finder.GetValue(2).ToString(); | ||
d = finder.GetValue(1).ToString(); | ||
}; | ||
|
||
// Assert | ||
|
||
action.Should().Throw<Exception>().WithMessage("can only be forward"); | ||
|
||
a.Should().Be(id); | ||
b.Should().Be(date); | ||
c.Should().Be(color); | ||
d.Should().BeNull(); | ||
} | ||
} | ||
} |
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