Пример #1
0
        public async Task UsesCustomJsonSerializerSettings()
        {
            var config = new HttpOutputConfiguration();

            config.ServiceUri = "http://*****:*****@"
                [
                    {
                        ""Timestamp"":""2018-01-02T14:12:00+00:00"",
                        ""ProviderName"":""HttpOutputTests"",
                        ""Level"":3,
                        ""Keywords"":0,
                        ""Payload"":{""InfinityProperty"":""Infinity""}
                    }
                ]".RemoveAllWhitespace();

            await output.SendEventsAsync(new EventData[] { e }, 78, CancellationToken.None);

            httpClientMock.Verify(client => client.PostAsync(
                                      new Uri("http://*****:*****@"
                [
                    {
                        ""Timestamp"":""2018-01-02T14:12:00+00:00"",
                        ""ProviderName"":""HttpOutputTests"",
                        ""Level"":3,
                        ""Keywords"":0,
                        ""Payload"":{""InfinityProperty"":0.0}
                    }
                ]".RemoveAllWhitespace();

            await output.SendEventsAsync(new EventData[] { e }, 79, CancellationToken.None);

            httpClientMock.Verify(client => client.PostAsync(
                                      new Uri("http://logcollector:1234"),
                                      It.Is <HttpContent>(content => content.ReadAsStringAsync().GetAwaiter().GetResult() == expectedContent)
                                      ), Times.Once());
        }
Пример #2
0
        public async Task ProducesJsonLinesIfRequested()
        {
            var config = new HttpOutputConfiguration();

            config.ServiceUri = "http://*****:*****@"
                {
                    ""Timestamp"":""2018-01-02T14:12:00+00:00"",
                    ""ProviderName"":""HttpOutputTests"",
                    ""Level"":4,
                    ""Keywords"":0,
                    ""Payload"":{""Message"":""Hey!""}
                }
                {
                    ""Timestamp"":""2018-01-02T14:14:20+00:00"",
                    ""ProviderName"":""HttpOutputTests"",
                    ""Level"":3,
                    ""Keywords"":0,
                    ""Payload"":{""Message"":""Hey!""}
                }";

            expectedContent = RemoveWhitespace(expectedContent);

            await output.SendEventsAsync(events, 78, CancellationToken.None);

            httpClientMock.Verify(client => client.PostAsync(
                                      new Uri("http://logcollector:1234"),
                                      It.Is <HttpContent>(content => RemoveWhitespace(content.ReadAsStringAsync().GetAwaiter().GetResult()) == expectedContent)
                                      ), Times.Once());
        }
Пример #3
0
        public async Task ProducesJsonByDefault()
        {
            var config = new HttpOutputConfiguration();

            config.ServiceUri = "http://*****:*****@"
                [
                    {
                        ""Timestamp"":""2018-01-02T14:12:00+00:00"",
                        ""ProviderName"":""HttpOutputTests"",
                        ""Level"":4,
                        ""Keywords"":0,
                        ""Payload"":{""Message"":""Hey!""}
                    },
                    {
                        ""Timestamp"":""2018-01-02T14:14:20+00:00"",
                        ""ProviderName"":""HttpOutputTests"",
                        ""Level"":3,
                        ""Keywords"":0,
                        ""Payload"":{""Message"":""Hey!""}
                    }]";

            expectedContent = RemoveWhitespace(expectedContent);

            await output.SendEventsAsync(events, 78, CancellationToken.None);

            httpClientMock.Verify(client => client.PostAsync(
                                      new Uri("http://logcollector:1234"),
                                      It.Is <HttpContent>(content => content.ReadAsStringAsync().GetAwaiter().GetResult() == expectedContent)
                                      ), Times.Once());
        }
Пример #4
0
        public async Task MethodInfoIsSerializedAsFullyQualifiedName()
        {
            var config = new HttpOutputConfiguration();

            config.ServiceUri = "http://*****:*****@"
                [
                    {
                        ""Timestamp"":""2018-01-02T14:12:00+00:00"",
                        ""ProviderName"":""HttpOutputTests"",
                        ""Level"":3,
                        ""Keywords"":0,
                        ""Payload"":{""Method"":""Microsoft.Diagnostics.EventFlow.Outputs.Tests.HttpOutputTests.MethodInfoIsSerializedAsFullyQualifiedName""}
                    }
                ]".RemoveAllWhitespace();

            await output.SendEventsAsync(new EventData[] { e }, 78, CancellationToken.None);

            httpClientMock.Verify(client => client.PostAsync(
                                      new Uri("http://logcollector:1234"),
                                      It.Is <HttpContent>(content => content.ReadAsStringAsync().GetAwaiter().GetResult() == expectedContent)
                                      ), Times.Once());
        }