示例#1
0
        public void WriterWritesLines()
        {
            // Given a writer
            var textWriter = new StringWriter();
            var writer     = new FakeCSVReaderWriter(f => null,
                                                     f => textWriter);

            // When I write a TSV
            writer.Open("Arbitrary", CSVReaderWriter.Mode.Write);
            writer.Write("First", "Second");
            writer.Close();

            // Then the string is written
            Assert.Equal($"First\tSecond{Environment.NewLine}", textWriter.ToString());
        }
示例#2
0
        public void WritingNothingWritesNothing()
        {
            var textWriter = new StringWriter();
            // Given a writer
            var writer = new FakeCSVReaderWriter(f => null,
                                                 f => textWriter);

            // When I write an empty string
            writer.Open("Arbitrary", CSVReaderWriter.Mode.Write);
            writer.Write(null);
            writer.Close();

            // Then nothing is written
            Assert.True(string.IsNullOrEmpty(textWriter.ToString()));
        }