Exemplo n.º 1
0
        public void Process_WithTwoReadingsWithSameNameButDifferentGroups_CreatesTwoFeatureStatsWithSameNamesButDifferentGroups()
        {
            IList <FeatureStatistics> featureStats = null;

            ReadingPublisher.Subscribe(GetSubscriber((dataPoints) =>
            {
                featureStats = dataPoints;
            }));
            string group1      = "Group1";
            string group2      = "Group2";
            string featureName = "featureName";

            ReadingPublisher.PublishReading(new Reading {
                FeatureName = featureName, FeatureGroup = group1, Data = new Int32ReadingData(1)
                {
                    Name = "Number"
                }
            });
            ReadingPublisher.PublishReading(new Reading {
                FeatureName = featureName, FeatureGroup = group2, Data = new Int32ReadingData(1)
                {
                    Name = "Error"
                }
            });

            ReadingPublisher.Start(100, false);
            ReadingPublisher.Process();

            Assert.That(featureStats.Count, Is.EqualTo(2));

            Assert.That(featureStats.First().Name, Is.EqualTo(featureStats.Last().Name));
            Assert.That(featureStats.First().Group, Is.EqualTo(group1));
            Assert.That(featureStats.Last().Group, Is.EqualTo(group2));
        }
Exemplo n.º 2
0
        public void Process_WithTwoReadingsWithSameNameButDifferentReadingDataNames_SendsOneDataPointToSubscribersWithTwoReadingDataValues()
        {
            IList <FeatureStatistics> passedDataPoints = null;

            ReadingPublisher.Subscribe(GetSubscriber((dataPoints) =>
            {
                passedDataPoints = dataPoints;
            }));
            ReadingPublisher.PublishReading(new Reading {
                FeatureName = "DataPointName", Data = new Int32ReadingData(1)
                {
                    Name = "Number"
                }
            });
            ReadingPublisher.PublishReading(new Reading {
                FeatureName = "DataPointName", Data = new Int32ReadingData(1)
                {
                    Name = "Error"
                }
            });

            ReadingPublisher.Start(100, false);
            ReadingPublisher.Process();

            FeatureStatistics dataPoint = passedDataPoints.First();

            Assert.That(dataPoint.Readings.Count, Is.EqualTo(2));
            Assert.That(dataPoint.Readings.First().Name, Is.EqualTo("Number"));
            Assert.That(dataPoint.Readings.Last().Name, Is.EqualTo("Error"));
        }
Exemplo n.º 3
0
        public void Add_AddsReadingToMonitor()
        {
            var reading = GetReading();

            ReadingPublisher.PublishReading(reading);

            Assert.AreEqual(1, ReadingPublisher.Readings.Count);
        }
        public void Process_With2ReadingsWithDifferentNames_PassesOnTwoSeparateDataPointsToSubscribers()
        {
            ReadingPublisher.PublishReading(GetNumberReading("test", 1));
            ReadingPublisher.PublishReading(GetNumberReading("test1", 1));

            ReadingPublisher.Process();

            Assert.That(_dataPoints.Count, Is.EqualTo(2));
        }
Exemplo n.º 5
0
        public void Process_ClearsReadingsFromReadingsQueue()
        {
            ReadingPublisher.PublishReading(GetReading());
            ReadingPublisher.PublishReading(GetReading());

            ReadingPublisher.Process();

            Assert.That(ReadingPublisher.Readings.Count, Is.EqualTo(0));
        }
Exemplo n.º 6
0
        public void Reset_ClearsAllMonitorReadings()
        {
            var reading = GetReading();

            ReadingPublisher.PublishReading(reading);

            ReadingPublisher.Reset();

            Assert.That(ReadingPublisher.Readings.Count, Is.EqualTo(0));
        }
        public void Process_WithMultipleReadings_CombinesTheReadingsIntoDataPoint()
        {
            string readingName = "test";

            ReadingPublisher.PublishReading(GetNumberReading(readingName, 1));
            ReadingPublisher.PublishReading(GetNumberReading(readingName, 1));

            ReadingPublisher.Process();

            Assert.That(_dataPoints.Count, Is.EqualTo(1));
            Assert.That(_dataPoints.First().Name, Is.EqualTo(readingName));
        }
        public void Process_WithMultipleReadings_PassesOnOneDataPointWithCombinedDataToSubscribers()
        {
            string readingName = "test";

            ReadingPublisher.PublishReading(GetNumberReading(readingName, 1));
            ReadingPublisher.PublishReading(GetNumberReading(readingName, 1));

            ReadingPublisher.Process();

            Assert.That(_dataPoints.Count, Is.EqualTo(1));
            Assert.That(_dataPoints.First().Readings.First().GetValue(), Is.EqualTo(2));
        }
Exemplo n.º 9
0
        protected void AddReading(ReadingData data)
        {
            if (string.IsNullOrEmpty(data.Name))
            {
                data.Name = ReadingName;
            }

            FeatureDescriptor descriptor = GetFeatureDescriptor();
            var newReading = new Reading {
                FeatureName = descriptor.Name, FeatureGroup = descriptor.Group, Data = data
            };

            ReadingPublisher.PublishReading(newReading);
        }
Exemplo n.º 10
0
        public void Process_WithAReading_SendsOneDataPointWithCurrentDate()
        {
            IList <FeatureStatistics> passedDataPoints = null;

            ReadingPublisher.Subscribe(GetSubscriber((dataPoints) =>
            {
                passedDataPoints = dataPoints;
            }));
            ReadingPublisher.PublishReading(new Reading {
                FeatureName = "DataPointName", Data = new Int32ReadingData(1)
                {
                    Name = "Number"
                }
            });

            ReadingPublisher.Start(100, false);
            ReadingPublisher.Process();

            Assert.That(passedDataPoints.First().Timestamp - DateTime.Now, Is.LessThan(TimeSpan.FromSeconds(1)));
        }
Exemplo n.º 11
0
        public void Process_WithAReading_CreatedFeatureWithCorrectGroup()
        {
            IList <FeatureStatistics> featurestats = null;

            ReadingPublisher.Subscribe(GetSubscriber((stats) =>
            {
                featurestats = stats;
            }));

            string group = "Group";

            ReadingPublisher.PublishReading(new Reading {
                FeatureName = "DataPointName", FeatureGroup = group, Data = new Int32ReadingData(1)
                {
                    Name = "Number"
                }
            });

            ReadingPublisher.Start(100, false);
            ReadingPublisher.Process();

            Assert.That(featurestats.First().Group, Is.EqualTo(group));
        }