Example #1
0
 public override string ToString() =>
 new ToStringBuilder(nameof(MetadataDto))
 {
     { nameof(Service), Service },
     { nameof(System), System },
     { nameof(Labels), AbstractConfigurationReader.ToLogString(Labels) }
 }.ToString();
 protected internal static LogLevel ParseWithoutLogging(string value)
 {
     if (AbstractConfigurationReader.TryParseLogLevel(value, out var level))
     {
         return(level);
     }
     return(ConsoleLogger.DefaultLogLevel);
 }
Example #3
0
            private static LogLevel ParseLogLevel(string valueAsString)
            {
                if (AbstractConfigurationReader.TryParseLogLevel(valueAsString, out var logLevel))
                {
                    return(logLevel);
                }

                throw new FormatException($"`{valueAsString}' is not a valid log level");
            }
Example #4
0
        private void FullFwAssertValid(Service service)
        {
            service.Should().NotBeNull();

            FullFwAssertValid(service.Framework);

            var expectedServiceName = AgentConfig.ServiceName
                                      ?? AbstractConfigurationReader.AdaptServiceName($"{Consts.SampleApp.SiteName}_{Consts.SampleApp.AppPoolName}");
            var expectedEnvironment = AgentConfig.Environment;

            service.Name.Should().Be(expectedServiceName);
            service.Environment.Should().Be(expectedEnvironment);
        }
Example #5
0
 public TestAgentComponents(
     string logLevel              = "Debug",
     string serverUrls            = null,
     Service service              = null,
     IPayloadSender payloadSender = null
     )
     : this(new TestAgentConfigurationReader(
                new TestLogger(AbstractConfigurationReader.ParseLogLevel(logLevel)),
                logLevel : logLevel,
                serverUrls : serverUrls
                ), service, payloadSender)
 {
 }
Example #6
0
        public CentralConfigTests(ITestOutputHelper xUnitOutputHelper)
            : base(
                xUnitOutputHelper,
                envVarsToSetForSampleAppPool: new Dictionary <string, string>
        {
            { ConfigConsts.EnvVarNames.ServiceName, CustomServiceName },
            { ConfigConsts.EnvVarNames.Environment, CustomEnvironment }
        })
        {
            ConfigState = new ConfigStateC(LoggerBase);

            AgentConfig.ServiceName = AbstractConfigurationReader.AdaptServiceName(CustomServiceName);
            AgentConfig.Environment = CustomEnvironment;
        }
        public void TestAbstractConfigurationReaderIsMsOrElastic()
        {
            var elasticToken  = new byte[] { 174, 116, 0, 210, 193, 137, 207, 34 };
            var mscorlibToken = new byte[] { 183, 122, 92, 86, 25, 52, 224, 137 };

            Assert.True(AbstractConfigurationReader.IsMsOrElastic(elasticToken));
            Assert.True(AbstractConfigurationReader.IsMsOrElastic(elasticToken));

            Assert.False(AbstractConfigurationReader.IsMsOrElastic(new byte[] { 0, }));
            Assert.False(AbstractConfigurationReader.IsMsOrElastic(new byte[] { }));

            Assert.False(AbstractConfigurationReader
                         .IsMsOrElastic(new byte[] { elasticToken[0], mscorlibToken[1], elasticToken[2],
                                                     mscorlibToken[3], elasticToken[4], mscorlibToken[5], elasticToken[6], mscorlibToken[7] }));
        }
Example #8
0
        private void FullFwAssertValid(Service service)
        {
            service.Should().NotBeNull();

            FullFwAssertValid(service.Framework);

            string expectedServiceName;

            if (AgentConfig.ServiceName == null)
            {
                expectedServiceName = AbstractConfigurationReader.AdaptServiceName($"{Consts.SampleApp.SiteName}_{Consts.SampleApp.AppPoolName}");
            }
            else
            {
                expectedServiceName = AgentConfig.ServiceName;
            }
            service.Name.Should().Be(expectedServiceName);
        }