Exemple #1
0
        protected TestsBase(
            ITestOutputHelper xUnitOutputHelper,
            bool startMockApmServer = true,
            IDictionary <string, string> envVarsToSetForSampleAppPool = null,
            bool sampleAppShouldHaveAccessToPerfCounters = false,
            bool sampleAppLogEnabled = true
            ) : base(xUnitOutputHelper)
        {
            _logger = LoggerBase.Scoped(ThisClassName);

            MockApmServer       = new MockApmServer(_logger, TestDisplayName);
            _iisAdministration  = new IisAdministration(_logger);
            _startMockApmServer = startMockApmServer;
            SampleAppShouldHaveAccessToPerfCounters = sampleAppShouldHaveAccessToPerfCounters;

            _mockApmServerPort = _startMockApmServer ? MockApmServer.FindAvailablePortToListen() : ConfigConsts.DefaultValues.ApmServerPort;

            _sampleAppLogEnabled  = sampleAppLogEnabled;
            _sampleAppLogFilePath = GetSampleAppLogFilePath();

            EnvVarsToSetForSampleAppPool = envVarsToSetForSampleAppPool == null
                                ? new Dictionary <string, string>()
                                : new Dictionary <string, string>(envVarsToSetForSampleAppPool);
            EnvVarsToSetForSampleAppPool.TryAdd(ConfigConsts.EnvVarNames.ServerUrls, BuildApmServerUrl(_mockApmServerPort));

            if (_sampleAppLogEnabled)
            {
                EnvVarsToSetForSampleAppPool.TryAdd(LoggingConfig.LogFileEnvVarName, _sampleAppLogFilePath);
            }

            EnvVarsToSetForSampleAppPool.TryAdd(ConfigConsts.EnvVarNames.FlushInterval, "10ms");
        }
Exemple #2
0
        protected TestsBase(ITestOutputHelper xUnitOutputHelper,
                            bool startMockApmServer = true,
                            IDictionary <string, string> envVarsToSetForSampleAppPool = null,
                            bool sampleAppShouldHaveAccessToPerfCounters = false,
                            bool sampleAppLogEnabled = true
                            )
        {
            _xUnitOutputHelper = xUnitOutputHelper;
            _logger            = new ToAllSinksLogger(_xUnitOutputHelper).Scoped(nameof(TestsBase));

            _logger.Info()?.Log("Starting test: {FullUnitTestName}", GetCurrentTestDisplayName(_xUnitOutputHelper));

            _mockApmServer      = new MockApmServer(_logger, GetCurrentTestDisplayName(_xUnitOutputHelper));
            _iisAdministration  = new IisAdministration(_logger);
            _startMockApmServer = startMockApmServer;
            SampleAppShouldHaveAccessToPerfCounters = sampleAppShouldHaveAccessToPerfCounters;

            _mockApmServerPort = _startMockApmServer ? _mockApmServer.FindAvailablePortToListen() : ConfigConsts.DefaultValues.ApmServerPort;

            _sampleAppLogEnabled  = sampleAppLogEnabled;
            _sampleAppLogFilePath = GetSampleAppLogFilePath();

            _envVarsToSetForSampleAppPool = envVarsToSetForSampleAppPool == null
                                ? new Dictionary <string, string>()
                                : new Dictionary <string, string>(envVarsToSetForSampleAppPool);
            _envVarsToSetForSampleAppPool.TryAdd(ConfigConsts.EnvVarNames.ServerUrls, BuildApmServerUrl(_mockApmServerPort));

            if (_sampleAppLogEnabled)
            {
                _envVarsToSetForSampleAppPool.TryAdd(LoggingConfig.LogFileEnvVarName, _sampleAppLogFilePath);
            }

            _envVarsToSetForSampleAppPool.TryAdd(ConfigConsts.EnvVarNames.FlushInterval, "10ms");
        }
Exemple #3
0
        protected TestsBase(ITestOutputHelper xUnitOutputHelper,
                            bool startMockApmServer = true,
                            Dictionary <string, string> envVarsToSetForSampleAppPool = null,
                            bool sampleAppShouldHaveAccessToPerfCounters             = false
                            )
        {
            _logger             = new XunitOutputLogger(xUnitOutputHelper).Scoped(nameof(TestsBase));
            _mockApmServer      = new MockApmServer(_logger, GetCurrentTestName(xUnitOutputHelper));
            _iisAdministration  = new IisAdministration(_logger);
            _startMockApmServer = startMockApmServer;
            SampleAppShouldHaveAccessToPerfCounters = sampleAppShouldHaveAccessToPerfCounters;

            _mockApmServerPort = _startMockApmServer ? _mockApmServer.FindAvailablePortToListen() : ConfigConsts.DefaultValues.ApmServerPort;

            _envVarsToSetForSampleAppPool = envVarsToSetForSampleAppPool == null
                                ? new Dictionary <string, string>()
                                : new Dictionary <string, string>(envVarsToSetForSampleAppPool);
            _envVarsToSetForSampleAppPool.TryAdd(ConfigConsts.EnvVarNames.ServerUrls, $"http://localhost:{_mockApmServerPort}");
        }