Esempio 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));
        }
Esempio 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"));
        }
 public void Setup()
 {
     _dataPoints = new List <FeatureStatistics>();
     ReadingPublisher.Start(100, false);
     ReadingPublisher.Subscribe(GetSubscriber((dp)
                                              =>
                                              _dataPoints.AddRange(dp)
                                              ));
 }
Esempio n. 4
0
        public void Initialise_100MsForProcessTime_StartsATimeThatCallsAfter100ms()
        {
            bool processed = false;

            ReadingPublisher.Subscribe(GetSubscriber((dataPoints) =>
            {
                processed = true;
            }));

            ReadingPublisher.Start(100);

            Thread.Sleep(300);

            Assert.That(processed, Is.True);
        }
Esempio n. 5
0
        public void Shutdown_StopsEnsuresProcessIsNotCalledAgain()
        {
            bool processed = false;

            Console.Write("Monitor Subscribers: " + ReadingPublisher.Subscribers.Count);
            Console.Write("processed: " + processed);
            ReadingPublisher.Subscribe(GetSubscriber((dataPoints) =>
            {
                processed = true;
            }));

            ReadingPublisher.Start(100);
            ReadingPublisher.Stop();
            Thread.Sleep(150);

            Assert.That(processed, Is.False);
        }
Esempio n. 6
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)));
        }
Esempio n. 7
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));
        }
Esempio n. 8
0
 public static void Initialise(GlobalFilterCollection filters, string featureName = null, string groupName = null)
 {
     filters.Add(new NotificationFilter(featureName, groupName));
     ReadingPublisher.Start((int)TimeSpan.FromMinutes(1).TotalMilliseconds);
 }
Esempio n. 9
0
 public void Setup()
 {
     ReadingPublisher.Start(1000, false);
 }