public void ExtractOnlyFirstLine(string delimiter, string input, string expected) { var splitter = new Rfc4180DataSplitter(); var firstLine = splitter.GetFirstLine(input, delimiter); firstLine.Should().Be(expected); }
public void ThrowErrorIfUsingDoubleQuoteAsColumnsDelimiter() { var splitter = new Rfc4180DataSplitter(); Action action = () => splitter.EnsureDelimitersAreValid(",", "\""); action.Should().Throw <BadDelimiterException>(); }
public void ThrowErrorIfNoEndQuoteFoundWhenExtractingLines(string delimiter, string input) { var splitter = new Rfc4180DataSplitter(); Action action = () => splitter.SplitLines(input, delimiter); action.Should().Throw <MissingQuoteException>(); }
public void DontThrowErrorIfSplitEmptyLine(string input) { var splitter = new Rfc4180DataSplitter(); var result = splitter.SplitLines(input, "\r\n"); result.Should().BeEmpty(); }
public void ReplaceAllNewLIneWithinDoubleQuotes(string delimiter, string input, string expected1, string expected2, string expected3) { var splitter = new Rfc4180DataSplitter(); var result = splitter.SplitLines(input, delimiter); result.Should().HaveCount(3); result[0].Should().Be(expected1); result[1].Should().Be(expected2); result[2].Should().Be(expected3); }
public void SplitColumnsInRfc4180(string delimiter, string input, string expected1, string expected2, string expected3) { var splitter = new Rfc4180DataSplitter(); var result = splitter.SplitColumns(input, delimiter); result.Should().HaveCount(3); result[0].Should().Be(expected1); result[1].Should().Be(expected2); result[2].Should().Be(expected3); }
public void DoubleQuoteTest() { const string input = @"277;237C3989-4D81-4F62-9581-A19516D08D86;2018-07-16 09:56:08.780;37;""{""""AggregateId"""":""""237c3989-4d81-4f62-9581-a19516d08d86"""",""""SiteId"""":""""237c3989-4d81-4f62-9581-a19516d08d86"""",""""Contact"""":{""""ContactId"""":""""42497b38-f0e4-497c-918f-61fb27d5a208"""",""""Nom"""":""""BRUCKER"""",""""Prenom"""":"""""""",""""TypeContactSiteId"""":""""7bfa472a-ab24-44d8-917b-360d1204364b"""",""""MoyensDeContact"""":{""""TelephoneFixe"""":"""""""",""""TelephonePortable"""":""""+33603644655"""",""""Email"""":"""""""",""""AdressePostale"""":{""""NumeroEtVoie"""":""""10 Rue du Lac"""",""""Complement"""":"""""""",""""CodePostal"""":""""67114"""",""""Commune"""":""""Eschau"""",""""Pays"""":""""France""""}},""""AutresInformations"""":""""""""},""""HorodateCreationUtc"""":""""2018-07-16T09:56:08.6962731Z"""",""""Journalisation"""":{""""UtilisateurId"""":""""00000000-0000-0000-0000-000000000000"""",""""TacheId"""":-1,""""Horodate"""":""""0001-01-01T00:00:00""""}}"""; var splitter = new Rfc4180DataSplitter(); var colums = splitter.SplitColumns(input, ";"); colums[4].Should().Contain("\"Complement\":\"\""); }