Inheritance: IRecordReduce
Ejemplo n.º 1
0
            public void ShouldBeAbleToReduce()
            {
                var testData = PopulateTestData(false);

                var reducer = new RecordReduce(testData.ReduceStatus.Object, testData.ReduceAggregater.Object, testData.Cache.Object, testData.ComparisonsData.Object, testData.Storage.Object, testData.DbProviderFactory.Object, testData.Settings.Object);
                reducer.Reduce("Single", true);

                Assert.Equal(1, testData.AggregateCount);
                Assert.Equal(1, testData.UpdateIfExistsCount);
                Assert.Equal(2, testData.CalculateCount);
                Assert.Equal(1, testData.DeletedCount);

                testData.Verify();
            }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
            public void ShouldNotRunIfWeAreAlreadyReducing()
            {
                var reduceStatus = new Mock<IRecordReduceStatus>();
                reduceStatus.Setup(x => x.IsReducing()).Returns(true).Verifiable();

                var settings = BuildSettings();

                var reducer = new RecordReduce(reduceStatus.Object, null, null, null, null, null, settings.Object);
                reducer.ReduceAll();

                reduceStatus.VerifyAll();
            }