public void StartSentryTransaction_CreatesValidTransaction()
    {
        // Arrange
        var context = HttpContextBuilder.Build();

        // Act
        var transaction = context.StartSentryTransaction();

        // Assert
        transaction.Name.Should().Be("GET /the/path");
        transaction.Operation.Should().Be("http.server");
    }
    public void StartSentryTransaction_BindsToScope()
    {
        // Arrange
        using var _ = SentrySdk.UseHub(new Hub(
                                           new SentryOptions { Dsn = "https://[email protected]:65535/2147483647" },
                                           Substitute.For <ISentryClient>()
                                           ));

        var context = HttpContextBuilder.Build();

        // Act
        var transaction          = context.StartSentryTransaction();
        var transactionFromScope = SentrySdk.GetSpan();

        // Assert
        transactionFromScope.Should().BeSameAs(transaction);
    }
    public void FinishSentryTransaction_FinishesTransaction()
    {
        // Arrange
        using var _ = SentrySdk.UseHub(new Hub(
                                           new SentryOptions
        {
            Dsn = "https://[email protected]:65535/2147483647"
        },
                                           Substitute.For <ISentryClient>()
                                           ));

        var context = HttpContextBuilder.Build(404);

        // Act
        var transaction = context.StartSentryTransaction();

        context.FinishSentryTransaction();

        // Assert
        transaction.IsFinished.Should().BeTrue();
        transaction.Status.Should().Be(SpanStatus.NotFound);
    }
Exemple #4
0
 protected HttpContextTest()
 {
     HttpContext.Current = Context = HttpContextBuilder.Build();
 }