Exemple #1
0
        public void WriteRecord_OneRecordWithRecordFormatter_RecordIsFormattedAndWritten()
        {
            var records = new string[]
            {
                "Record 1"
            };

            var formattedRecords = new string[]
            {
                "Formatted Record 1"
            };

            var recordFormatter = MockRepository.GenerateMock <IRecordFormatter>();

            recordFormatter.Expect(x => x.Format(Arg <object> .Is.Equal(records[0]))).Return(formattedRecords[0]).Repeat.Once();

            using (var stream = new MemoryStream())
                using (var streamWriter = new TextStreamWriter(stream, recordFormatter))
                {
                    streamWriter.Open();

                    foreach (var record in records)
                    {
                        streamWriter.WriteRecord(record);
                    }

                    streamWriter.Commit();

                    TextStreamWriterTests.AssertStreamContentMatchesRecords(stream, formattedRecords);
                }

            recordFormatter.VerifyAllExpectations();
        }
Exemple #2
0
        public void WriteRecord_OneRecord_RecordIsWritten()
        {
            var records = new string[]
            {
                "Record 1"
            };

            using (var stream = new MemoryStream())
                using (var streamWriter = new TextStreamWriter(stream))
                {
                    streamWriter.Open();

                    foreach (var record in records)
                    {
                        streamWriter.WriteRecord(record);
                    }

                    streamWriter.Commit();

                    TextStreamWriterTests.AssertStreamContentMatchesRecords(stream, records);
                }
        }