public void ShouldOpenFileAndReadStream() { var mockstream = new Mock <Stream>(); mockstream.Setup(x => x.CanRead).Returns(true); var streamreader = new StreamReader(mockstream.Object); _csvWriter.Open(Filename); var stream = _csvWriter.GetWriter(); Assert.That(stream, Is.EqualTo(streamreader)); _csvWriter.Close(); }
//Keep the open method for backward compatibility public void Open(string fileName, Mode mode) { if (mode == Mode.Read) { _csvReader.Open(fileName); } else if (mode == Mode.Write) { _csvWriter.Open(fileName); } }
public void Open(string fileName, Mode mode) { switch (mode) { case Mode.Read: _csvReader.Open(fileName); break; case Mode.Write: _csvWriter.Open(fileName); break; default: throw new Exception("Unknown file mode for " + fileName); } }