Inheritance: IRecorder
Esempio n. 1
0
            public void WhenHasResolutionAllLikeTimesShouldBeGrouped()
            {
                var monitorInfo = BuildDefaultMonitorInfo(1000);
                var recordMocks = BuildRecordMocks(monitorInfo);

                var recorder = new Recorder(recordMocks.Cache.Object, recordMocks.Settings.Object);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 452), 1, MonitorReductionType.DefaultAccumulate);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 453), 1, MonitorReductionType.DefaultAccumulate);
                recorder.Record("Test", new DateTime(1995, 06, 06, 1, 32, 23, 454), 1, MonitorReductionType.DefaultAccumulate);

                Assert.Equal(monitorInfo.MonitorRecords.Count, 1);
                Assert.Equal(monitorInfo.MonitorRecords[0].Number, 3);
            }
Esempio n. 2
0
            public void ShouldThrowExceptionWhenNoSeedConfigIsFound()
            {
                var seeder = new Mock<IConfigSeed>();
                seeder.Setup(x => x.Seed("Test", MonitorReductionType.DefaultAccumulate)).Verifiable();

                var settings = BuildSettings();
                settings.SetupGet(x => x.Debug).Returns(true);
                settings.SetupGet(x => x.ConfigSeed).Returns(seeder.Object);

                var cache = new Mock<IDataCache>();

                var recorder = new Recorder(cache.Object, settings.Object);

                Assert.Throws<Exception>(() => recorder.Record("Test", DateTime.Now, 1, MonitorReductionType.DefaultAccumulate));

                seeder.VerifyAll();
            }
Esempio n. 3
0
        public void Initialize(SettingsExtensionOptions settingsExtensionOptions)
        {
            //Need to setup the logger first
            LoggerProvider = settingsExtensionOptions.LoggerProvider ?? new SystemLoggerProvider(this);

            var storageFactory = settingsExtensionOptions.StorageFactory;
            if (settingsExtensionOptions.StorageFactory == null)
            {
                var storageFactoryProvider = new StorageFactoryProvider();
                storageFactory = storageFactoryProvider.CreateProvider();
            }
            var storageCommands = settingsExtensionOptions.StorageCommands ?? new StorageCommands(storageFactory, this);
            var storageCommandsSetup = settingsExtensionOptions.StorageCommandsSetup ?? new StorageCommandsSetup();

            var cache = new DataCache();
            var flusherUpdate = new RecordFlushUpdate(cache, storageCommands);
            var reduceStatus = new RecordReduceStatus(new RecordReduceStatusSourceProviderFile(this));
            var reduceAggregate = new RecordReduceAggregate();
            var compare = new RecordCompare(storageCommands, this);

            var setupSystemTables = new SetupSystemTables(cache, storageCommandsSetup, this);
            var setupSystemData = new SetupSystemData(cache, storageCommandsSetup, this);
            var setupSystem = new SetupSystem(setupSystemTables, setupSystemData, storageFactory);
            var defineDefaults = new SetupMonitorConfig(storageCommands, setupSystemTables, cache, storageFactory, this);

            ConfigSeed = new ConfigSeed(cache, this);
            Recorder = new Recorder(cache, this);
            RecordFlush = new RecordFlush(defineDefaults, cache, storageCommands, flusherUpdate, storageFactory, this);
            RecordReduce = new RecordReduce(reduceStatus, reduceAggregate, cache, compare, storageCommands, storageFactory, this);

            ReduceMethodProvider = new ReduceMethodProvider();
            ReduceMethodProvider.Register(new ReduceMethodAccumulate());
            ReduceMethodProvider.Register(new ReduceMethodAverage());
            ProcessingInstructionProvider = new ProcessingInstructionProvider();
            ProcessingInstructionProvider.Register(new ProcessingInstructionAccumulate(storageCommands));
            ProcessingInstructionProvider.Register(new ProcessingInstructionAverage());

            //Run system setup
            setupSystem.Initialize();
        }
Esempio n. 4
0
            public void WhenResolutionIsZeroShouldAddToUpdateList()
            {
                var monitorInfo = BuildDefaultMonitorInfo(0);
                var recordMocks = BuildRecordMocks(monitorInfo);

                var recorder = new Recorder(recordMocks.Cache.Object, recordMocks.Settings.Object);
                recorder.RecordEvent("Test");

                Assert.Equal(monitorInfo.MonitorRecords.Count, 1);
            }