public void Sender_HasExpectedUserAgent()
        {
            var httpClient = SentryHttpClient.CreateHttpClient();

            Assert.Equal(SentryHttpClient.UserAgent,
                         httpClient.DefaultRequestHeaders.UserAgent.ToString());
        }
        public void DisposesSender()
        {
            var sender = new TestSender(new HttpClientHandler());

            var client = new SentryHttpClient(DsnTests.SentryDsn,
                                              sender);

            client.Dispose();

            Assert.True(sender.IsDisposed);
        }
        public async Task DisabledClient_ReturnsEmptyResponse()
        {
            var senderMock = new Mock <HttpClient>();

            var client = new SentryHttpClient(null, senderMock.Object);

            var response = await client.SendEventAsync(
                new SentryEventData());

            senderMock.Verify(s => s.SendAsync(It.IsAny <HttpRequestMessage>(),
                                               It.IsAny <CancellationToken>()),
                              Times.Never());

            Assert.NotNull(response);
            Assert.Null(response.EventId);
        }
Beispiel #4
0
        public async Task SendMessageEvent(string message)
        {
            var senderMock = new Mock <HttpClient>();
            var client     = new SentryHttpClient(Dsn, senderMock.Object);

            senderMock.Setup(m => m.SendAsync(It.IsAny <HttpRequestMessage>(), None))
            .ReturnsAsync(CreateOkHttpResponse(JsonSerializer.CreateDefault()))
            .Verifiable();

            var response = await client.SendEventAsync(new SentryEventData
            {
                Message = message
            });

            senderMock.Verify();

            Assert.Equal(200, response.StatusCode);
            Assert.NotNull(response.EventId);
            Assert.Null(response.SentryError);
        }
 public void CreateDefault()
 => Assert.NotNull(
     SentryHttpClient.Default(DsnTests.SentryDsn));
Beispiel #6
0
 public static SentryClient CreateClient(Dsn dsn)
 => SentryHttpClient.Default(dsn);