Example #1
0
        public async Task Factory_LogsFrameworkOptions()
        {
            IOptionsLoggingSource source = new OptionsLoggingSource();

            IOptionsFactory <LoggerFilterOptions> factory = new WebJobsOptionsFactory <LoggerFilterOptions>(
                Enumerable.Empty <IConfigureOptions <LoggerFilterOptions> >(),
                Enumerable.Empty <IPostConfigureOptions <LoggerFilterOptions> >(),
                source,
                new LoggerFilterOptionsFormatter());

            LoggerFilterOptions options = factory.Create(null);

            source.LogStream.Complete();

            IList <string>        logs      = new List <string>();
            ISourceBlock <string> logStream = source.LogStream;

            while (await logStream.OutputAvailableAsync(CancellationToken.None))
            {
                logs.Add(await logStream.ReceiveAsync());
            }

            string log = logs.Single();

            string expected =
                "LoggerFilterOptions" + Environment.NewLine +
                "{" + Environment.NewLine +
                "  \"MinLevel\": \"Trace\"," + Environment.NewLine +
                "  \"Rules\": []" + Environment.NewLine +
                "}";

            Assert.Equal(expected, log);
        }
Example #2
0
        public async Task Factory_LogsOptions()
        {
            IOptionsLoggingSource source = new OptionsLoggingSource();

            IOptionsFactory <TestOptions> factory = new WebJobsOptionsFactory <TestOptions>(
                Enumerable.Empty <IConfigureOptions <TestOptions> >(),
                Enumerable.Empty <IPostConfigureOptions <TestOptions> >(),
                source);

            TestOptions options = factory.Create(null);

            source.LogStream.Complete();

            IList <string>        logs      = new List <string>();
            ISourceBlock <string> logStream = source.LogStream;

            while (await logStream.OutputAvailableAsync(CancellationToken.None))
            {
                logs.Add(await logStream.ReceiveAsync());
            }

            string log = logs.Single();

            string expected =
                "TestOptions" + Environment.NewLine +
                "{" + Environment.NewLine +
                "  \"SomeValue\": \"abc123\"" + Environment.NewLine +
                "}";

            Assert.Equal(expected, log);
        }