コード例 #1
0
        public void appendSeriesToOutputBuffer_ThereAreThreeSeries_NoDummySeries()
        {
            IInputBuffer[]  inputBuffers;
            IOutputBuffer[] outputBuffers;
            getIOBuffers(out inputBuffers, out outputBuffers, 3);
            var records = new[]
            {
                new Record(new double[] { 3 }),
                new Record(new double[] { 2 }),
                new Record(new double[] { 1 })
            };

            inputBuffers[2].HasNext().Returns(true, true, true, true, true, true, false);
            inputBuffers[2].GetNextRecord().Returns(records[0], records[1], records[2]);
            inputBuffers[2].HasDummy().Returns(false);

            var distributionBuffering = new DistributionBufferingIO(ref inputBuffers, ref outputBuffers, 2);

            distributionBuffering.WriteNextSeriesToBuffer(0);
            distributionBuffering.WriteNextSeriesToBuffer(0);
            distributionBuffering.WriteNextSeriesToBuffer(0);

            inputBuffers[2].Received(3).GetNextRecord();
            outputBuffers[0].Received().AppendRecord(records[0]);
            outputBuffers[0].Received().AppendRecord(records[1]);
            outputBuffers[0].Received().AppendRecord(records[2]);
        }
コード例 #2
0
        public void GetInputBuffer_OutputBufferIsAtIndex0_InputBufferWithIndex0ShouldNotBeReturned()
        {
            var expectedRecord = Record.Max;

            IInputBuffer[]  inputBuffers;
            IOutputBuffer[] outputBuffers;
            getIOBuffers(out inputBuffers, out outputBuffers, 3);

            outputBuffers[0].LastAppendedRecord.Returns(expectedRecord);
            outputBuffers[1].LastAppendedRecord.Returns(expectedRecord);
            outputBuffers[2].LastAppendedRecord.Returns(Record.NullRecord);

            var distributionBuffering = new DistributionBufferingIO(ref inputBuffers, ref outputBuffers, 2);

            Assert.AreEqual(expectedRecord, distributionBuffering.GetOutputBuffer(0).LastAppendedRecord);
            Assert.AreEqual(expectedRecord, distributionBuffering.GetOutputBuffer(1).LastAppendedRecord);
        }
コード例 #3
0
        public void getNextRecordValueFromSourceInputBuffer()
        {
            var goodRecord = new Record(new double[] { 1, 1, 1, });
            var badRecord  = new Record(new double[] { 0, 0, 0 });

            var sourceInputBuffer = Substitute.For <IInputBuffer>();

            sourceInputBuffer.GetNextRecord().Returns(goodRecord);
            sourceInputBuffer.HasNext().Returns(true);
            sourceInputBuffer.RemoveDummyRecord().Throws(new Exception("No dummy records should be removed here!"));
            var sourceOutputBuffer = Substitute.For <IOutputBuffer>();

            sourceOutputBuffer.LastAppendedRecord.Returns(goodRecord);

            var tempInputBuffers  = new IInputBuffer[4];
            var tempOutputBuffers = new IOutputBuffer[4];

            for (var i = 0; i < 3; i++)
            {
                tempInputBuffers[i] = Substitute.For <IInputBuffer>();
                tempInputBuffers[i].GetNextRecord().Returns(badRecord);
                tempInputBuffers[i].HasNext().Returns(true);
                tempOutputBuffers[i] = Substitute.For <IOutputBuffer>();
                tempOutputBuffers[i].LastAppendedRecord.Returns(badRecord);
            }

            tempInputBuffers[3]  = sourceInputBuffer;
            tempOutputBuffers[3] = sourceOutputBuffer;

            var fileBufferIO = new DistributionBufferingIO(ref tempInputBuffers, ref tempOutputBuffers, 3);

            var actualRecord = fileBufferIO.GetNextFromCurrentInputBuffer();

            Assert.AreEqual(false, actualRecord.IsDummy);
            Assert.AreEqual(goodRecord.Value, actualRecord.Value);
        }