Beispiel #1
0
        public void ProcessingIsMoreExpensiveThanReading_NanosecondsLevel()
        {
            FakeCallback callback = new FakeCallback(100000, TimeSpan.FromTicks(30), TimeSpan.FromTicks(100));
            var          reader   = new SequentialMediaReaderAndProcessor <object, object, object>(callback, CancellationToken.None);

            for (int i = 0; i < callback.ItemsCount; ++i)
            {
                object obj = reader.ReadAndProcessNextPieceOfData();
                Assert.AreEqual(FakeCallback.ItemIdxToData(i), (int)obj);
                FakeCallback.DoFakeJob(TimeSpan.FromTicks(8));
            }
        }
Beispiel #2
0
        public void ClientStopsReadingInTheMiddleOfSenquence()
        {
            FakeCallback callback = new FakeCallback(20, TimeSpan.FromMilliseconds(20), TimeSpan.FromMilliseconds(100));
            var          reader   = new SequentialMediaReaderAndProcessor <object, object, object>(callback, CancellationToken.None);

            for (int i = 0; i < callback.ItemsCount / 2; ++i)
            {
                object obj = reader.ReadAndProcessNextPieceOfData();
                Assert.AreEqual(FakeCallback.ItemIdxToData(i), (int)obj);
                FakeCallback.DoFakeJob(TimeSpan.FromMilliseconds(20));
            }
        }
        public void ProcessingIsLessExpensiveThanReading()
        {
            FakeCallback callback = new FakeCallback(20, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(20));
            var          reader   = new SequentialMediaReaderAndProcessor <object, object, object>(callback);

            for (int i = 0; i < callback.ItemsCount; ++i)
            {
                object obj = reader.ReadAndProcessNextPieceOfData();
                Assert.AreEqual(FakeCallback.ItemIdxToData(i), (int)obj);
                FakeCallback.DoFakeJob(TimeSpan.FromMilliseconds(20));
            }
        }
Beispiel #4
0
        public void NullIsReturnedWhenEOFReached_CorrectValueOtherwise()
        {
            FakeCallback callback = new FakeCallback(50, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20));
            var          reader   = new SequentialMediaReaderAndProcessor <object, object, object>(callback, CancellationToken.None);

            for (int i = 0;; ++i)
            {
                object obj = reader.ReadAndProcessNextPieceOfData();
                if (i == callback.ItemsCount)
                {
                    Assert.IsNull(obj);
                }
                else
                {
                    Assert.AreEqual(FakeCallback.ItemIdxToData(i), (int)obj);
                }
                if (obj == null)
                {
                    break;
                }
            }
        }