| | 1 | | using ValidateLib.ResultCreators; |
| | 2 | | using ValidateLib.Results; |
| | 3 | |
|
| | 4 | | namespace ResultWriterTests |
| | 5 | | { |
| | 6 | | public class CsvResultWriterTests : BaseTest |
| | 7 | | { |
| | 8 | | [Fact] |
| | 9 | | public void WriterCreatesAFile() |
| 1 | 10 | | { |
| 1 | 11 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 12 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 13 | | resultWriter.GenerateResult(pathNonExisting, new TableGroupValidationResultDetails()); |
| 1 | 14 | | Assert.True(File.Exists(pathNonExisting)); |
| 1 | 15 | | } |
| | 16 | |
|
| | 17 | | [Fact] |
| | 18 | | public void WriterCreatesNonEmptyFile() |
| 1 | 19 | | { |
| 1 | 20 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 21 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 22 | | resultWriter.GenerateResult(pathNonExisting, new TableGroupValidationResultDetails()); |
| 1 | 23 | | var content = File.ReadAllText(pathNonExisting); |
| 1 | 24 | | Assert.True(content != string.Empty); |
| 1 | 25 | | } |
| | 26 | |
|
| | 27 | | [Fact] |
| | 28 | | public void WriterCreatesNonEmptyFileWithGeneralError() |
| 1 | 29 | | { |
| 1 | 30 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 31 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 32 | | var tableGroupResults = GetResultWithGeneralError(); |
| 1 | 33 | | resultWriter.GenerateResult(pathNonExisting, tableGroupResults); |
| 1 | 34 | | var content = File.ReadAllText(pathNonExisting); |
| 1 | 35 | | Assert.True(content != string.Empty); |
| 1 | 36 | | } |
| | 37 | |
|
| | 38 | | [Fact] |
| | 39 | | public void WriterCreatesNonEmptyFileWithGeneralWarning() |
| 1 | 40 | | { |
| 1 | 41 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 42 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 43 | | var tableGroupResults = GetResultWithGeneralWarning(); |
| 1 | 44 | | resultWriter.GenerateResult(pathNonExisting, tableGroupResults); |
| 1 | 45 | | var content = File.ReadAllText(pathNonExisting); |
| 1 | 46 | | Assert.True(content != string.Empty); |
| 1 | 47 | | } |
| | 48 | |
|
| | 49 | | [Fact] |
| | 50 | | public void WriterCreatesNonEmptyFileWithTableError() |
| 1 | 51 | | { |
| 1 | 52 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 53 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 54 | | var tableGroupResults = GetResultWithTableError(); |
| 1 | 55 | | resultWriter.GenerateResult(pathNonExisting, tableGroupResults); |
| 1 | 56 | | var content = File.ReadAllText(pathNonExisting); |
| 1 | 57 | | Assert.True(content != string.Empty); |
| 1 | 58 | | } |
| | 59 | |
|
| | 60 | | [Fact] |
| | 61 | | public void WriterCreatesNonEmptyFileWithTableWarning() |
| 1 | 62 | | { |
| 1 | 63 | | var resultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| 1 | 64 | | var pathNonExisting = "non_existing.csv"; |
| 1 | 65 | | var tableGroupResults = GetResultWithTableWarning(); |
| 1 | 66 | | resultWriter.GenerateResult(pathNonExisting, tableGroupResults); |
| 1 | 67 | | var content = File.ReadAllText(pathNonExisting); |
| 1 | 68 | | Assert.True(content != string.Empty); |
| 1 | 69 | | } |
| | 70 | | } |
| | 71 | | } |