Esempio n. 1
0
 public void CollectingNoValuesDoesNotPlotAnything()
 {
     var probeReader = new Mock<IProbeReaderAdapter>();
     var dataLogger = new Mock<IDataLoggerAdapter>();
     var dataPlotter = new ThreadSafeDataPlotter(new [] { probeReader.Object}, dataLogger.Object);
     dataPlotter.Collect(0);
     dataLogger.Verify(d => d.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()), Times.Never);
 }
Esempio n. 2
0
        public void CollectedValuesArePlotted()
        {
            var values = Enumerable.Range(0, 5).Select(x => DateTime.MinValue.AddHours(x)).Select(x => new DataValueAdapter(x, null)).ToList();
            var probeReader = new MockProbeReader(values);

            var dataLogger = new Mock<IDataLoggerAdapter>();
            dataLogger.Setup(x => x.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()))
                .Callback<IEnumerable<DataValueAdapter>>(plottedValues => Assert.That(plottedValues, Is.EqualTo(values)));
            var dataPlotter = new ThreadSafeDataPlotter(new[] { probeReader }, dataLogger.Object);

            dataPlotter.Collect(5);
            dataLogger.Verify(d => d.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()));
        }
Esempio n. 3
0
        public void CollectsValuesInFullBatchesFive(int numberOfValuesToCollect)
        {
            var probeReader = new Mock<IProbeReaderAdapter>();
            probeReader.Setup(x => x.Read()).Returns(ReturnTestValue);
            var dataLogger = new Mock<IDataLoggerAdapter>();
            var dataPlotter = new ThreadSafeDataPlotter(new[] { probeReader.Object}, dataLogger.Object);

            dataPlotter.Collect(numberOfValuesToCollect);

            int completeBatchesOfFive = numberOfValuesToCollect / 5;
            dataLogger.Verify(d => d.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()), Times.Exactly(completeBatchesOfFive));
        }
Esempio n. 4
0
        public void CollectsValuesDespiteNonTerminatingProbeReaders()
        {
            var values = Enumerable.Range(0, 5).Select(x => DateTime.MinValue.AddHours(x)).Select(x => new DataValueAdapter(x, null)).ToList();
            var probeReader = new MockProbeReader(values);
            var hangingProbeReader = new Mock<IProbeReaderAdapter>();
            hangingProbeReader.Setup(x => x.Read()).Returns(Hang());
            var probeReaderAdapters = new[] { hangingProbeReader.Object, probeReader, hangingProbeReader.Object};

            var dataLogger = new Mock<IDataLoggerAdapter>();
            dataLogger.Setup(x => x.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()))
                .Callback<IEnumerable<DataValueAdapter>>(plottedValues => Assert.That(plottedValues, Is.EqualTo(values)));

            var dataPlotter = new ThreadSafeDataPlotter(probeReaderAdapters, dataLogger.Object);

            dataPlotter.Collect(5);
            dataLogger.Verify(d => d.Plot(It.IsAny<IEnumerable<DataValueAdapter>>()));
        }