Ejemplo n.º 1
0
        public void WriteRecord_OneRecord_RecordIsWritten()
        {
            var record        = new object();
            var recordWritten = (object)null;
            var writeRecord   = new Action <object>(r => recordWritten = r);

            var dataWriter = new MockDataWriter(writeRecord);

            dataWriter.WriteRecord(record);

            Assert.AreEqual(record, recordWritten);
        }
Ejemplo n.º 2
0
        public void WriteRecord_RecordFormatterThrowsException_ExceptionIsPropogated()
        {
            var record          = new object();
            var formattedRecord = new object();
            var writeRecord     = new Action <object>(r => Assert.Fail());
            var recordFormatter = MockRepository.GenerateMock <IRecordFormatter>();

            recordFormatter.Stub(x => throw new InternalTestFailureException());

            var dataWriter = new MockDataWriter(recordFormatter, writeRecord);

            dataWriter.WriteRecord(record);
        }
Ejemplo n.º 3
0
        public void WriteRecord_OneRecordWithRecordFormatter_RecordIsFormattedAndWritten()
        {
            var record          = new object();
            var formattedRecord = new object();
            var recordWritten   = (object)null;
            var writeRecord     = new Action <object>(r => recordWritten = r);
            var recordFormatter = MockRepository.GenerateMock <IRecordFormatter>();

            recordFormatter.Expect(x => x.Format(Arg <object> .Is.Equal(record))).Return(formattedRecord).Repeat.Once();

            var dataWriter = new MockDataWriter(recordFormatter, writeRecord);

            dataWriter.WriteRecord(record);

            recordFormatter.VerifyAllExpectations();

            Assert.AreEqual(formattedRecord, recordWritten);
        }
Ejemplo n.º 4
0
        public void WriteRecord_TwoRecords_RecordsAreWritten()
        {
            var records = new List <object>()
            {
                new object(),
                new object()
            };
            var recordsWritten = new List <object>();
            var writeRecord    = new Action <object>(r => recordsWritten.Add(r));

            var dataWriter = new MockDataWriter(writeRecord);

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

            CollectionAssert.AreEquivalent(records, recordsWritten);
        }