public void RecordFormatter_GivenNullFileReader_ThrowsNullReferenceExceptionOnFileRead() { sut.IRecordFormatter sut = new sut.RecordFormatter(null); Assert.Throws <NullReferenceException>( () => sut.FormatFile(string.Empty, string.Empty, false) ); Assert.Throws <NullReferenceException>( () => sut.FormatFile(string.Empty, string.Empty, false, false) ); }
public void FormatSubRecords_GivenRecordsAndDefaultLineEndingNormalization_ReturnsExpectedRecords( string[] records, string subRecordDelimiter, bool removeBlankRecords, IEnumerable <IEnumerable <string> > expectedRecords ) { sut.IRecordFormatter sut = new sut.RecordFormatter(null); var result = sut.FormatSubRecords(records, subRecordDelimiter, removeBlankRecords); Assert.Equal(expectedRecords, result); }
public void RecordFormatter_Constructor_SetsFileReader() { var reader = new Mock <IFileReader>(); var expected = new string[] { "Record 1", "Record 2" }; reader.Setup(r => r.ReadFile(It.IsAny <string>())).Returns("Record 1\nRecord 2"); sut.IRecordFormatter sut = new sut.RecordFormatter(reader.Object); var actual = sut.FormatFile(string.Empty, "\n", false); Assert.Equal(expected, actual); }
public void FormatRecord_GivenRecords_ReturnsExpectedRecords( string records, string recordDelimiter, bool removeBlankRecords, bool normalizeLineEndings, string[] expectedRecords ) { sut.IRecordFormatter sut = new sut.RecordFormatter(null); var result = sut.FormatRecord(records, recordDelimiter, removeBlankRecords, normalizeLineEndings); Assert.Equal(expectedRecords, result); }
public void FormatFile_GivenFilesAndDefaultLineEndingNormalization_ReturnsExpectedRecords( string fileContents, string recordDelimiter, bool removeBlankRecords, IEnumerable <string> expectedRecords ) { var reader = new Mock <IFileReader>(); reader .Setup(r => r.ReadFile(It.IsAny <string>())) .Returns(fileContents); sut.IRecordFormatter sut = new sut.RecordFormatter(reader.Object); var result = sut.FormatFile(string.Empty, recordDelimiter, removeBlankRecords); Assert.Equal(expectedRecords, result); }