/// <summary> /// Asserts on 1 transaction /// </summary> private MockPayloadSender AssertWith1Transaction(Action <ApmAgent> action) { var payloadSender = new MockPayloadSender(); var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender)); action(agent); Assert.NotEmpty(payloadSender.Payloads); Assert.NotEmpty(payloadSender.Payloads[0].Transactions); Assert.Equal(TransactionName, payloadSender.Payloads[0].Transactions[0].Name); Assert.Equal(TransactionType, payloadSender.Payloads[0].Transactions[0].Type); var duration = payloadSender.Payloads[0].Transactions[0].Duration; WaitHelpers.AssertMinimumSleepLength(duration); return(payloadSender); }
/// <summary> /// Asserts on 1 transaction with async code /// </summary> private async Task <MockPayloadSender> AssertWith1TransactionAsync(Func <ApmAgent, Task> func) { var payloadSender = new MockPayloadSender(); var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender)); await func(agent); Assert.NotEmpty(payloadSender.Payloads); Assert.NotEmpty(payloadSender.Payloads[0].Transactions); Assert.Equal(TransactionName, payloadSender.Payloads[0].Transactions[0].Name); Assert.Equal(TransactionType, payloadSender.Payloads[0].Transactions[0].Type); var duration = payloadSender.Payloads[0].Transactions[0].Duration; WaitHelpers.AssertMinimumSleepLength(duration); return(payloadSender); }
/// <summary> /// Asserts on 1 transaction and 1 error /// </summary> private void AssertWith1TransactionAnd1Error(Action <ApmAgent> action) { var payloadSender = new MockPayloadSender(); var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender)); action(agent); Assert.NotEmpty(payloadSender.Payloads); Assert.NotEmpty(payloadSender.Payloads[0].Transactions); Assert.Equal(TransactionName, payloadSender.Payloads[0].Transactions[0].Name); Assert.Equal(TransactionType, payloadSender.Payloads[0].Transactions[0].Type); var duration = payloadSender.Payloads[0].Transactions[0].Duration; WaitHelpers.AssertMinimumSleepLength(duration); Assert.NotEmpty(payloadSender.Errors); Assert.NotEmpty(payloadSender.Errors[0].Errors); Assert.Equal(typeof(InvalidOperationException).FullName, payloadSender.Errors[0].Errors[0].Exception.Type); Assert.Equal(ExceptionMessage, payloadSender.Errors[0].Errors[0].Exception.Message); }