Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fraliv13 committed Dec 11, 2024
1 parent e1d09b0 commit 2b55b52
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ await _inner.PublishAsync(message, options with { EnvelopeCustomizer = NewCustom
catch (Exception exception)
{
activity?.SetStatus(ActivityStatusCode.Error, exception.Message);
activity?.RecordException(exception);
activity?.AddException(exception);
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async Task NewHandler(MessagingEnvelope<TMessage> incommingEnvelope)
catch (Exception exception)
{
activity?.SetStatus(ActivityStatusCode.Error, exception.Message);
activity?.RecordException(exception);
activity?.AddException(exception);
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public void Emit(LogEvent logEvent)

if (logEvent.Exception != null)
{
activity.RecordException(logEvent.Exception);
activity.AddException(logEvent.Exception);
}
}
catch (Exception logException)
{
activity.RecordException(logException);
activity.AddException(logException);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions test/UnitTests/Core/NBB.Core.Pipeline.Tests/PipelineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace NBB.Core.Pipeline.Tests
public class PipelineTests
{
[Fact]
public async void Should_execute_nesting_in_order_class_middleware()
public async Task Should_execute_nesting_in_order_class_middleware()
{
//Arrange
var mockedServiceProvider = Mock.Of<IServiceProvider>();
Expand All @@ -35,7 +35,7 @@ public async void Should_execute_nesting_in_order_class_middleware()
}

[Fact]
public async void Should_execute_nesting_in_order_inline()
public async Task Should_execute_nesting_in_order_inline()
{
//Arrange
var mockedServiceProvider = Mock.Of<IServiceProvider>();
Expand Down Expand Up @@ -67,7 +67,7 @@ public async void Should_execute_nesting_in_order_inline()


[Fact]
public async void Should_support_constructor_injection_in_middleware()
public async Task Should_support_constructor_injection_in_middleware()
{
//Arrange
var mockedServiceProvider = Mock.Of<IServiceProvider>(sp =>
Expand All @@ -87,7 +87,7 @@ public async void Should_support_constructor_injection_in_middleware()
}

[Fact]
public async void Should_pass_execution_parameters_to_middleware()
public async Task Should_pass_execution_parameters_to_middleware()
{
//Arrange
var mockedServiceProvider = Mock.Of<IServiceProvider>();
Expand Down Expand Up @@ -125,7 +125,7 @@ public async void Should_pass_execution_parameters_to_middleware()
}

[Fact]
public async void Should_not_swallow_exception_async()
public async Task Should_not_swallow_exception_async()
{
//Arrange
var mockedServiceProvider = Mock.Of<IServiceProvider>();
Expand Down Expand Up @@ -185,7 +185,7 @@ public void Should_not_burry_exception_sync()
}

[Fact]
public async void Should_build_pipeline_in_container_scope()
public async Task Should_build_pipeline_in_container_scope()
{
//Arrange
var services = new ServiceCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CorrelationMiddlewareTests
{
// IntegrationTest (integrates with CorrelationManager)
[Fact]
public async void Should_setNewCorrelationId()
public async Task Should_setNewCorrelationId()
{
//Arrange
var correlationMiddleWare = new CorrelationMiddleware();
Expand All @@ -34,7 +34,7 @@ public async void Should_setNewCorrelationId()

// IntegrationTest (integrates with CorrelationManager)
[Fact]
public async void Should_takeCorrelationIdFromMessage()
public async Task Should_takeCorrelationIdFromMessage()
{
//Arrange
var correlationMiddleWare = new CorrelationMiddleware();
Expand All @@ -53,7 +53,7 @@ public async void Should_takeCorrelationIdFromMessage()
}

[Fact]
public async void Should_callNextPipelineMiddleware()
public async Task Should_callNextPipelineMiddleware()
{
//Arrange
var correlationMiddleWare = new CorrelationMiddleware();
Expand All @@ -71,4 +71,4 @@ public async void Should_callNextPipelineMiddleware()
isNextMiddlewareCalled.Should().BeTrue();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace NBB.Messaging.Host.Tests.MessagingPipeline
public class DefaultResiliencyMiddlewareTests
{
[Fact]
public async void Should_callNextPipelineMiddleware()
public async Task Should_callNextPipelineMiddleware()
{
//Arrange
var resiliencyMiddleware = new DefaultResiliencyMiddleware(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace NBB.Messaging.Host.Tests.MessagingPipeline
public class ExceptionHandlingMiddlewareTests
{
[Fact]
public async void Should_logSuccessMessage()
public async Task Should_logSuccessMessage()
{
//Arrange
var mockedLogger = Mock.Of<ILogger<ExceptionHandlingMiddleware>>();
Expand All @@ -34,7 +34,7 @@ public async void Should_logSuccessMessage()
}

[Fact]
public async void Should_logErrorMessageWhenExceptionIsThrown()
public async Task Should_logErrorMessageWhenExceptionIsThrown()
{
//Arrange
var mockedLogger = Mock.Of<ILogger<ExceptionHandlingMiddleware>>();
Expand All @@ -61,7 +61,7 @@ public async void Should_logErrorMessageWhenExceptionIsThrown()
}

[Fact]
public async void Should_callNextPipelineMiddleware()
public async Task Should_callNextPipelineMiddleware()
{
//Arrange

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace NBB.Messaging.Host.Tests.MessagingPipeline
public class MediatRMiddlewareTests
{
[Fact]
public async void Should_publishEventsToMediatR()
public async Task Should_publishEventsToMediatR()
{
//Arrange
var mockedMediator = Mock.Of<IMediator>();
Expand All @@ -34,7 +34,7 @@ public async void Should_publishEventsToMediatR()
}

[Fact]
public async void Should_sendCommandsToMediatR()
public async Task Should_sendCommandsToMediatR()
{
//Arrange
var mockedMediator = Mock.Of<IMediator>();
Expand All @@ -54,7 +54,7 @@ public async void Should_sendCommandsToMediatR()
}

[Fact]
public async void Should_throwExceptionForUnhandledMessageType()
public async Task Should_throwExceptionForUnhandledMessageType()
{
//Arrange
var mediatRMiddleware = new MediatRMiddleware(Mock.Of<IMediator>());
Expand All @@ -75,7 +75,7 @@ public async void Should_throwExceptionForUnhandledMessageType()
}

[Fact]
public async void Should_callNextPipelineMiddleware()
public async Task Should_callNextPipelineMiddleware()
{
//Arrange
var mediatRMiddleware = new MediatRMiddleware(Mock.Of<IMediator>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NBB.Messaging.Host.Tests.MessagingPipeline
public class SchemaMessageValidatorMiddlewareTests
{
[Fact]
public async void Should_throwExceptionWhenAHeaderFieldIsNotProvided()
public async Task Should_throwExceptionWhenAHeaderFieldIsNotProvided()
{
//Arrange
var schemaMessageValidationMiddleware = new SchemaMessageValidatorMiddleware();
Expand All @@ -34,7 +34,7 @@ public async void Should_throwExceptionWhenAHeaderFieldIsNotProvided()
}

[Fact]
public async void Should_callNextPipelineMiddlewareWhenAllHeaderFieldsAreProvided()
public async Task Should_callNextPipelineMiddlewareWhenAllHeaderFieldsAreProvided()
{
//Arrange
bool isNextMiddlewareCalled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace NBB.Messaging.MultiTenancy.Tests
public class MessageBusPublisherDecoratorTests
{
[Fact]
public async void ShouldCallInnerPublisher()
public async Task ShouldCallInnerPublisher()
{
// Arrange
var publisherMock = new Mock<IMessageBusPublisher>();
Expand All @@ -39,7 +39,7 @@ public async void ShouldCallInnerPublisher()
}

[Fact]
public async void ShouldSetTenantIdInEnvelopeHeader()
public async Task ShouldSetTenantIdInEnvelopeHeader()
{
// Arrange
var tenantId = Guid.NewGuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This source code is licensed under the MIT license.

using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
using NBB.Messaging.Abstractions;
using Xunit;
Expand All @@ -24,7 +25,7 @@ public TenantIdHeaderMessagingTokenResolverTests()
}

[Fact]
public void Should_Resolve_Token_FromHeader()
public async Task Should_Resolve_Token_FromHeader()
{
// Arrange
const string key = "test token key";
Expand All @@ -33,21 +34,21 @@ public void Should_Resolve_Token_FromHeader()
var sut = new TenantIdHeaderMessagingTokenResolver(_mockMessagingContextAccessor, key);

// Act
var result = sut.GetTenantToken().Result;
var result = await sut.GetTenantToken();

// Assert
result.Should().Be(value);
}

[Fact]
public void Should_Return_Null_For_Bad_Keys()
public async Task Should_Return_Null_For_Bad_Keys()
{
// Arrange
const string key = "bad token key";
var sut = new TenantIdHeaderMessagingTokenResolver(_mockMessagingContextAccessor, key);

// Act
var result= sut.GetTenantToken().Result;
var result = await sut.GetTenantToken();

// Assert
result.Should().BeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
using FluentAssertions;
using NBB.MultiTenancy.Identification.Identifiers;
using System;
using System.Threading.Tasks;
using Xunit;

namespace NBB.MultiTenancy.Identification.Tests.Identifiers
{
public class IdTenantIdentifierTests
{
[Fact]
public void Should_Return_Given_Guid()
public async Task Should_Return_Given_Guid()
{
// Arrange
var sut = new IdTenantIdentifier();
var testGuid = Guid.NewGuid();

// Act
var tenantId = sut.GetTenantIdAsync(testGuid.ToString()).Result;
var tenantId = await sut.GetTenantIdAsync(testGuid.ToString());

// Assert
tenantId.Should().Be(testGuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Should_Throw_TenantNotFoundException_If_All_Resolvers_Return_Null()
}

[Fact]
public void Should_Pass_Token_And_Stop()
public async Task Should_Pass_Token_And_Stop()
{
// Arrange
const string tenantToken = "mock token";
Expand All @@ -60,14 +60,14 @@ public void Should_Pass_Token_And_Stop()
var sut = new DefaultTenantIdentificationService(new List<TenantIdentificationStrategy>() { firstPair, secondPair, thirdPair });

// Act
_ = sut.GetTenantIdAsync().Result;
_ = await sut.GetTenantIdAsync();

// Assert
_identifier.Verify(i => i.GetTenantIdAsync(It.Is<string>(s => string.Equals(s, tenantToken))), Times.Once());
}

[Fact]
public void Try_Method_Should_Return_Null_If_All_Resolvers_Return_Null()
public async Task Try_Method_Should_Return_Null_If_All_Resolvers_Return_Null()
{
// Arrange
_firstResolver.Setup(r => r.GetTenantToken()).Returns(Task.FromResult<string>(null));
Expand All @@ -77,14 +77,14 @@ public void Try_Method_Should_Return_Null_If_All_Resolvers_Return_Null()
var sut = new DefaultTenantIdentificationService(new List<TenantIdentificationStrategy>() { identifierPair });

// Act
var result = sut.TryGetTenantIdAsync().Result;
var result = await sut.TryGetTenantIdAsync();

// Assert
result.Should().BeNull();
}

[Fact]
public void Try_Method_Should_Pass_Token_And_Stop()
public async Task Try_Method_Should_Pass_Token_And_Stop()
{
// Arrange
const string tenantToken = "mock token";
Expand All @@ -97,7 +97,7 @@ public void Try_Method_Should_Pass_Token_And_Stop()
var sut = new DefaultTenantIdentificationService(new List<TenantIdentificationStrategy>() { firstPair, secondPair, thirdPair });

// Act
_ = sut.TryGetTenantIdAsync().Result;
_ = await sut.TryGetTenantIdAsync();

// Assert
_identifier.Verify(i => i.GetTenantIdAsync(It.Is<string>(s => string.Equals(s, tenantToken))), Times.Once());
Expand Down

0 comments on commit 2b55b52

Please sign in to comment.