Exemple #1
0
        public void SetUp()
        {
            _compositeTestAgent = new CompositeTestAgent();
            var environment          = _compositeTestAgent.Container.Resolve <IEnvironment>();
            var collectorWireFactory = Mock.Create <ICollectorWireFactory>();

            _collectorWire = Mock.Create <ICollectorWire>();
            var systemInfo       = Mock.Create <ISystemInfo>();
            var processStatic    = Mock.Create <IProcessStatic>();
            var agentEnvironment = new NewRelic.Agent.Core.Environment(systemInfo, processStatic);

            Mock.Arrange(() => collectorWireFactory.GetCollectorWire(null, Arg.IsAny <IAgentHealthReporter>())).IgnoreArguments().Returns(_collectorWire);
            Mock.Arrange(() => _collectorWire.SendData("preconnect", Arg.IsAny <ConnectionInfo>(), Arg.IsAny <string>()))
            .Returns("{'return_value': { 'redirect_host': ''}}");

            _agentHealthReporter = Mock.Create <IAgentHealthReporter>();

            _connectionHandler = new ConnectionHandler(new JsonSerializer(), collectorWireFactory, Mock.Create <IProcessStatic>(), Mock.Create <IDnsStatic>(),
                                                       Mock.Create <ILabelsService>(), agentEnvironment, systemInfo, _agentHealthReporter, Mock.Create <IEnvironment>());
        }
        public void Setup()
        {
            _compositeTestAgent = new CompositeTestAgent();
            var environment          = _compositeTestAgent.Container.Resolve <IEnvironment>();
            var collectorWireFactory = Mock.Create <ICollectorWireFactory>();

            _collectorWire = Mock.Create <ICollectorWire>();
            var systemInfo          = Mock.Create <ISystemInfo>();
            var processStatic       = Mock.Create <IProcessStatic>();
            var agentEnvironment    = new NewRelic.Agent.Core.Environment(systemInfo, processStatic);
            var agentHealthReporter = Mock.Create <IAgentHealthReporter>();

            Mock.Arrange(() => collectorWireFactory.GetCollectorWire(null, Arg.IsAny <IAgentHealthReporter>())).IgnoreArguments().Returns(_collectorWire);
            Mock.Arrange(() => environment.GetEnvironmentVariable("NEW_RELIC_SECURITY_POLICIES_TOKEN")).Returns("ffff-fbff-ffff-ffff");

            _connectRawData = string.Empty;
            _receivedSecurityPoliciesException = false;

            _connectionHandler = new ConnectionHandler(new JsonSerializer(), collectorWireFactory, Mock.Create <IProcessStatic>(), Mock.Create <IDnsStatic>(),
                                                       Mock.Create <ILabelsService>(), agentEnvironment, systemInfo, agentHealthReporter, Mock.Create <IEnvironment>());
        }