public void CsvToJsonFileConverter_Converts_EmptyFile(string fileName) { var path = Path.Combine(ResourceFolder, fileName); var extension = Path.GetExtension(fileName).Replace(".", ""); var bytes = File.ReadAllBytes(path); var c2jc = new CsvToJsonFileConverter(); c2jc.Convert(extension, "json", bytes, null).Count().ShouldBe(0); }
public void CsvToJsonFileConverter_SupportedConversions() { var c2jc = new CsvToJsonFileConverter(); var sc = c2jc.SupportedConversions; sc.Count().ShouldBe(1); sc.Any(c => c.SourceExtension == "csv" && c.DestinationExtension == "json").ShouldBeTrue(); }
public void CsvToJsonFileConverter_Converts(string fileName) { var path = Path.Combine(ResourceFolder, fileName); var extension = Path.GetExtension(fileName).Replace(".", ""); var bytes = File.ReadAllBytes(path); var c2jc = new CsvToJsonFileConverter(); var delimiter = fileName.IndexOf("tab", StringComparison.InvariantCultureIgnoreCase) > 0 ? '\t' : ','; var converted = c2jc.Convert(extension, "json", bytes, new { @delimiter = delimiter }); var actualJson = Encoding.ASCII.GetString(converted); actualJson.ShouldBe(SomeDataExpectedJson); }
public void CsvToJsonFileConverter_Convert_Throws() { var c2jc = new CsvToJsonFileConverter(); //nullreference Should.Throw <NullReferenceException>(() => c2jc.Convert("csv", "json", null, null)); //unsupported var bytes = new byte[] { 1, 1, 0, 0 }; Should.Throw <NotSupportedException>(() => c2jc.Convert("dadada", "json", bytes, null)); Should.Throw <NotSupportedException>(() => c2jc.Convert("csv", "ss", bytes, null)); Should.Throw <NotSupportedException>(() => c2jc.Convert("s", "ss", bytes, null)); }