public void Given_ValidCsvRow_Should_GetValidEntity() { string csvLine = "23,Michael Jordan"; var player = CsvLoader.Map <Player>(csvLine); Assert.IsNotNull(player); Assert.AreEqual(player.No, 23); Assert.AreEqual(player.Name, "Michael Jordan"); }
public void Given_InvalidTypeMapping_Should_BeAbleToIgnoreConvertError() { // wrong positions expected there would be converting error string csvLine = "Michael Jordan,23"; // set ignoreConvertErro = true to avoid exceptions var player = CsvLoader.Map <Player>(csvLine, ignoreConvertError: true); Assert.IsNotNull(player); Assert.AreEqual(player.No, default(int)); Assert.AreEqual(player.Name, "23"); }
public void Given_IncorrectColumnIndex_Should_ThrowIndexOutOfRangeException() { string csvLine = "23,Michael Jordan"; var player = CsvLoader.Map <PlayerHasOutBoundaryColumnPosition>(csvLine, ignoreConvertError: false, ignoreIndexOutOfRange: false); }