示例#1
0
        public void logs_one_item()
        {
            var clientRequest = new StubHttpClientEvent();

            _testSubject.Invoke(clientRequest);

            _logger.Logs.Count.ShouldBe(1);
        }
示例#2
0
        public void serialise_client_event_with_inner_exception()
        {
            var clientRequest = new StubHttpClientEvent
            {
                EventType = "SimpleWithNestedException",
                Exception = new Exception("the-message", new ApplicationException("inner"))
            };

            _testSubject.Invoke(clientRequest);

            _logger.Logs[0].ShouldBe("{\"eventType\":\"SimpleWithNestedException\",\"timestamp\":\"0001-01-01T00:00:00+00:00\",\"exception\":{\"type\":\"Exception\",\"message\":\"the-message\",\"innerException\":{\"type\":\"ApplicationException\",\"message\":\"inner\"}}}");
        }
示例#3
0
        public void serialise_client_event_with_exception()
        {
            var clientRequest = new StubHttpClientEvent
            {
                EventType = "SimpleWithException",
                Exception = new ExceptionWithStackTrace("the-message")
            };

            _testSubject.Invoke(clientRequest);

            _logger.Logs[0].ShouldBe("{\"eventType\":\"SimpleWithException\",\"timestamp\":\"0001-01-01T00:00:00+00:00\",\"exception\":{\"type\":\"ExceptionWithStackTrace\",\"message\":\"the-message\",\"stackTrace\":\"the-stack-trace\"}}");
        }
示例#4
0
        public void should_log_event_with_tags()
        {
            var lastRequest = new StubHttpClientEvent();

            _testSubject.Invoke(lastRequest);

            lastRequest.Tags.ShouldNotBeNull();
            lastRequest.Tags.ShouldContainKeyAndValue("outboundRequestId", _outboundRequestId);
            lastRequest.Tags.ShouldContainKeyAndValue("inboundRequestId", _inboundRequestId);
            lastRequest.Tags.ShouldContainKeyAndValue("correlationId", _correlationId);
            lastRequest.Tags.ShouldContainKeyAndValue("sessionId", _sessionId);
            lastRequest.Tags.ShouldContainKeyAndValue("service", "appName");
            lastRequest.Tags.ShouldContainKeyAndValue("version", "appVersion");
        }
示例#5
0
        public void serialise_simple_client_event()
        {
            var clientRequest = new StubHttpClientEvent
            {
                EventType = "Simple",
                Request   = _request,
                Method    = "GET",
                Uri       = $"{_baseAddress}ping",
                Timestamp = new DateTimeOffset(2016, 11, 18, 19, 52, 6, TimeSpan.Zero).AddTicks(4425454)
            };

            _testSubject.Invoke(clientRequest);

            _logger.Logs[0].ShouldBe("{\"eventType\":\"Simple\",\"timestamp\":\"2016-11-18T19:52:06.4425454+00:00\",\"method\":\"GET\",\"uri\":\"http://localhost:8080/ping\"}");
        }