Example #1
0
        public void When_custom_events_disabled_harvest_is_not_scheduled()
        {
            _configurationAutoResponder.Dispose();
            _customEventAggregator.Dispose();
            var configuration = Mock.Create <IConfiguration>();

            Mock.Arrange(() => configuration.CustomEventsEnabled).Returns(false);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);
            _customEventAggregator      = new CustomEventAggregator(_dataTransportService, _scheduler, _processStatic, _agentHealthReporter);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());

            Mock.Assert(() => _scheduler.StopExecuting(null, null), Args.Ignore());
        }
Example #2
0
        public void SetUp()
        {
            var configuration = GetDefaultConfiguration();

            Mock.Arrange(() => configuration.CollectorSendDataOnExit).Returns(true);
            Mock.Arrange(() => configuration.CollectorSendDataOnExitThreshold).Returns(0);
            Mock.Arrange(() => configuration.CustomEventsHarvestCycle).Returns(ConfiguredHarvestCycle);
            _configurationAutoResponder = new ConfigurationAutoResponder(configuration);

            _dataTransportService = Mock.Create <IDataTransportService>();
            _agentHealthReporter  = Mock.Create <IAgentHealthReporter>();
            _processStatic        = Mock.Create <IProcessStatic>();
            _attribDefSvc         = new AttributeDefinitionService((f) => new AttributeDefinitions(f));

            _scheduler = Mock.Create <IScheduler>();
            Mock.Arrange(() => _scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; });
            _customEventAggregator = new CustomEventAggregator(_dataTransportService, _scheduler, _processStatic, _agentHealthReporter);

            EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent());
        }