-
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.
feat: improve handling of custom types (#103)
- Loading branch information
Showing
10 changed files
with
193 additions
and
424 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
32 changes: 32 additions & 0 deletions
32
PocketCsvReader.Testing/FieldParsing/TypeParserLocatorTest.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,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using PocketCsvReader.FieldParsing; | ||
|
||
namespace PocketCsvReader.Testing.FieldParsing; | ||
public class TypeParserLocatorTest | ||
{ | ||
[Test] | ||
[TestCase("Q1.25", "'Q'q.yy")] | ||
public void Locate_YearQuarterTwoParameters_FindIt(string input, string format) | ||
{ | ||
var locator = new TypeParserLocator<Chrononuensis.YearQuarter>(); | ||
var func = locator.Locate([format, CultureInfo.InvariantCulture]); | ||
var value = func.Invoke(input); | ||
Assert.That(value, Is.EqualTo(new Chrononuensis.YearQuarter(2025, 1))); | ||
} | ||
|
||
[Test] | ||
[TestCase("2025-Q1")] | ||
public void Locate_YearQuarterSingleParameter_FindIt(string input) | ||
{ | ||
var locator = new TypeParserLocator<Chrononuensis.YearQuarter>(); | ||
var func = locator.Locate([CultureInfo.InvariantCulture]); | ||
var value = func.Invoke(input); | ||
Assert.That(value, Is.EqualTo(new Chrononuensis.YearQuarter(2025, 1))); | ||
} | ||
} |
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
Oops, something went wrong.