From f479752744950c0b2e32bacf019078ea23dd6129 Mon Sep 17 00:00:00 2001 From: Stephen Liedig Date: Sat, 12 Aug 2023 13:00:49 +0800 Subject: [PATCH] feat: replaced moq with NSubsitute --- .../ContractsService.Tests.csproj | 6 +- .../CreateContractFunctionTest.cs | 19 ++- .../UpdateContractFunctionTest.cs | 47 +++--- .../ContractsService/ContractsService.csproj | 4 +- .../UpdateContractFunction.cs | 4 +- .../PropertiesApprovalSyncFunctionTest.cs | 154 +++++++++--------- .../PropertiesService.Tests.csproj | 8 +- .../PropertiesService.csproj | 4 +- .../ApprovalService.Tests.csproj | 6 +- .../RequestApprovalFunctionTest.cs | 37 ++--- .../ApprovalService/ApprovalService.csproj | 4 +- .../ApprovalService/RequestApprovalRequest.cs | 1 - Unicorn.Web/Common/Common.csproj | 4 +- .../PropertySearchFunctionTest.cs | 14 +- .../SearchService.Tests.csproj | 6 +- .../SearchService/SearchService.csproj | 2 +- 16 files changed, 153 insertions(+), 167 deletions(-) diff --git a/Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj b/Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj index 12b82a7..2211cf7 100755 --- a/Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj +++ b/Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj @@ -10,11 +10,11 @@ - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Unicorn.Contracts/ContractsService.Test/CreateContractFunctionTest.cs b/Unicorn.Contracts/ContractsService.Test/CreateContractFunctionTest.cs index ef2ccf0..94e2e73 100755 --- a/Unicorn.Contracts/ContractsService.Test/CreateContractFunctionTest.cs +++ b/Unicorn.Contracts/ContractsService.Test/CreateContractFunctionTest.cs @@ -7,10 +7,12 @@ using System.Threading.Tasks; using Amazon.DynamoDBv2.DataModel; using Amazon.Lambda.APIGatewayEvents; -using Moq; +using NSubstitute; using Xunit; using Xunit.Abstractions; +[assembly: CollectionBehavior(DisableTestParallelization = true)] + namespace Unicorn.Contracts.ContractService.Tests; [Collection("Sequential")] @@ -31,10 +33,10 @@ public async Task CreateValidContractPublishesDraftContractStatusChangedEvent() { // Arrange var request = TestHelpers.LoadApiGatewayProxyRequest("./events/create_valid_event.json"); - - var mockDynamoDbContext = new Mock(); - var mockPublisher = new Mock(); + var mockDynamoDbContext = Substitute.For(); + + var mockPublisher = Substitute.For(); var context = TestHelpers.NewLambdaContext(); @@ -45,13 +47,12 @@ public async Task CreateValidContractPublishesDraftContractStatusChangedEvent() }; var function = - new CreateContractFunction(mockDynamoDbContext.Object, mockPublisher.Object); + new CreateContractFunction(mockDynamoDbContext, mockPublisher); var response = await function.FunctionHandler(request, context); - - mockPublisher.Verify( - client => client.PublishEvent(It.IsAny()), Times.Once); //TODO: Verify with contract status = DRAFT - + + await mockPublisher.Received(1).PublishEvent(Arg.Any()); + _testOutputHelper.WriteLine("Lambda Response: \n" + response.Body); _testOutputHelper.WriteLine("Expected Response: \n" + expectedResponse.Body); diff --git a/Unicorn.Contracts/ContractsService.Test/UpdateContractFunctionTest.cs b/Unicorn.Contracts/ContractsService.Test/UpdateContractFunctionTest.cs index 44c3bb1..14633c3 100755 --- a/Unicorn.Contracts/ContractsService.Test/UpdateContractFunctionTest.cs +++ b/Unicorn.Contracts/ContractsService.Test/UpdateContractFunctionTest.cs @@ -3,12 +3,13 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Net; using System.Threading; using System.Threading.Tasks; using Amazon.DynamoDBv2.DataModel; using Amazon.Lambda.APIGatewayEvents; -using Moq; +using NSubstitute; using Xunit; using Xunit.Abstractions; @@ -22,7 +23,7 @@ public class UpdateContractFunctionTest public UpdateContractFunctionTest(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; - + // Set env variable for Powertools Metrics Environment.SetEnvironmentVariable("POWERTOOLS_METRICS_NAMESPACE", "ContractService"); } @@ -31,27 +32,25 @@ public UpdateContractFunctionTest(ITestOutputHelper testOutputHelper) public async Task UpdateContractPublishesApprovedContractStatusChangedEvent() { var request = TestHelpers.LoadApiGatewayProxyRequest("./events/update_valid_event.json"); - - var mockDynamoDbContext = new Mock(); - var retContract = new Contract() - { - PropertyId = "usa/anytown/main-street/123", - ContractId = Guid.NewGuid(), - Address = new Address() + + var mockDynamoDbContext = Substitute.For(); + + mockDynamoDbContext.LoadAsync(Arg.Any(), Arg.Any()) + .Returns(new Contract() { - City = "anytown", - Number = 123, - Street = "main-street" - } - }; - - mockDynamoDbContext - .Setup(x => x.LoadAsync(It.IsAny(), CancellationToken.None).Result) - .Returns(retContract); - - var mockPublisher = new Mock(); + PropertyId = "usa/anytown/main-street/123", + ContractId = Guid.NewGuid(), + Address = new Address() + { + City = "anytown", + Number = 123, + Street = "main-street" + } + }); + + var mockPublisher = Substitute.For(); - var context = TestHelpers.NewLambdaContext(); + var context = TestHelpers.NewLambdaContext(); var expectedResponse = new APIGatewayProxyResponse { @@ -59,12 +58,10 @@ public async Task UpdateContractPublishesApprovedContractStatusChangedEvent() Headers = new Dictionary { { "Content-Type", "application/json" } } }; - var function = new UpdateContractFunction(mockDynamoDbContext.Object, mockPublisher.Object); + var function = new UpdateContractFunction(mockDynamoDbContext, mockPublisher); var response = await function.FunctionHandler(request, context); - mockPublisher.Verify( - client => client.PublishEvent(It.IsAny()), Times.Once); - //TODO: Verify with contract status = DRAFT + await mockPublisher.Received(1).PublishEvent(Arg.Any()); _testOutputHelper.WriteLine("Lambda Response: \n" + response.Body); _testOutputHelper.WriteLine("Expected Response: \n" + expectedResponse.Body); diff --git a/Unicorn.Contracts/ContractsService/ContractsService.csproj b/Unicorn.Contracts/ContractsService/ContractsService.csproj index ba61f58..be6a598 100755 --- a/Unicorn.Contracts/ContractsService/ContractsService.csproj +++ b/Unicorn.Contracts/ContractsService/ContractsService.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/Unicorn.Contracts/ContractsService/UpdateContractFunction.cs b/Unicorn.Contracts/ContractsService/UpdateContractFunction.cs index 47ac1ac..f83d612 100644 --- a/Unicorn.Contracts/ContractsService/UpdateContractFunction.cs +++ b/Unicorn.Contracts/ContractsService/UpdateContractFunction.cs @@ -63,9 +63,9 @@ public UpdateContractFunction(IDynamoDBContext dynamoDbContext, IPublisher publi /// API Gateway Lambda Proxy Request that triggers the function. /// The context for the Lambda function. /// API Gateway Lambda Proxy Response. - [Tracing] + [Logging(LogEvent = true)] [Metrics(CaptureColdStart = true)] - [Logging(LogEvent = true, CorrelationIdPath = CorrelationIdPaths.ApiGatewayRest)] + [Tracing(CaptureMode = TracingCaptureMode.ResponseAndError)] public async Task FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) { diff --git a/Unicorn.Properties/PropertiesService.Tests/PropertiesApprovalSyncFunctionTest.cs b/Unicorn.Properties/PropertiesService.Tests/PropertiesApprovalSyncFunctionTest.cs index 0f5bc92..7370fab 100755 --- a/Unicorn.Properties/PropertiesService.Tests/PropertiesApprovalSyncFunctionTest.cs +++ b/Unicorn.Properties/PropertiesService.Tests/PropertiesApprovalSyncFunctionTest.cs @@ -4,7 +4,7 @@ using Amazon.DynamoDBv2.DataModel; using Amazon.StepFunctions; using Amazon.StepFunctions.Model; -using Moq; +using NSubstitute; using Xunit; using Xunit.Abstractions; @@ -39,33 +39,31 @@ public void StatusIsDraftSyncShouldNotSendTaskSuccess() // Setup var ddbEvent = TestHelpers.LoadDynamoDbEventSource("./events/StreamEvents/contract_status_changed_draft.json"); - var retContractStatusItem = new ContractStatusItem - { - PropertyId = "usa/anytown/main-street/999", - ContractId = Guid.NewGuid(), - ContractStatus = "DRAFT", - ContractLastModifiedOn = DateTime.Today, - SfnWaitApprovedTaskToken = null - }; - - var mockDynamoDbContext = new Mock(); - - mockDynamoDbContext - .Setup(x => x.LoadAsync(It.IsAny(), CancellationToken.None).Result) - .Returns(retContractStatusItem); - - var mockStepFunctionsClient = new Mock(); - + var mockDynamoDbContext = Substitute.For(); + + mockDynamoDbContext.LoadAsync(Arg.Any(), Arg.Is(CancellationToken.None)) + .Returns(new ContractStatusItem + { + PropertyId = "usa/anytown/main-street/999", + ContractId = Guid.NewGuid(), + ContractStatus = "DRAFT", + ContractLastModifiedOn = DateTime.Today, + SfnWaitApprovedTaskToken = null + }); + + var mockStepFunctionsClient = Substitute.ForPartsOf(); + mockStepFunctionsClient.Received(0) + .SendTaskSuccessAsync(Arg.Any(), + Arg.Any()); + var context = TestHelpers.NewLambdaContext(); var function = - new PropertiesApprovalSyncFunction(mockStepFunctionsClient.Object, mockDynamoDbContext.Object); + new PropertiesApprovalSyncFunction(mockStepFunctionsClient, mockDynamoDbContext); + + var handler = function.FunctionHandler(ddbEvent, context); - function.FunctionHandler(ddbEvent, context); - mockStepFunctionsClient.Verify( - client => client.SendTaskSuccessAsync(It.IsAny(), - It.IsAny()), Times.Never); } @@ -75,32 +73,32 @@ public Task StatusIsApprovedNoTokenSyncShouldNotSendTaskSuccess() var ddbEvent = TestHelpers.LoadDynamoDbEventSource("./events/StreamEvents/contract_status_changed_approved.json"); - var retContractStatusItem = new ContractStatusItem - { - PropertyId = "usa/anytown/main-street/999", - ContractId = Guid.NewGuid(), - ContractStatus = "APPROVED", - ContractLastModifiedOn = DateTime.Today, - SfnWaitApprovedTaskToken = null - }; - - var mockDynamoDbContext = new Mock(); - mockDynamoDbContext - .Setup(x => x.LoadAsync(It.IsAny(), CancellationToken.None).Result) - .Returns(retContractStatusItem); - - var mockStepFunctionsClient = new Mock(); - + var mockDynamoDbContext = Substitute.For(); + mockDynamoDbContext.LoadAsync(Arg.Any(), Arg.Any()) + .Returns(new ContractStatusItem + { + PropertyId = "usa/anytown/main-street/999", + ContractId = Guid.NewGuid(), + ContractStatus = "APPROVED", + ContractLastModifiedOn = DateTime.Today, + SfnWaitApprovedTaskToken = null + }); + + var mockStepFunctionsClient = Substitute.ForPartsOf(); + mockStepFunctionsClient.Received(0). + SendTaskSuccessAsync(Arg.Any(), + Arg.Any()); + var context = TestHelpers.NewLambdaContext(); var function = - new PropertiesApprovalSyncFunction(mockStepFunctionsClient.Object, mockDynamoDbContext.Object); + new PropertiesApprovalSyncFunction(mockStepFunctionsClient, mockDynamoDbContext); function.FunctionHandler(ddbEvent, context); - mockStepFunctionsClient.Verify( - client => client.SendTaskSuccessAsync(It.IsAny(), - It.IsAny()), Times.Never); + mockStepFunctionsClient.Received(0). + SendTaskSuccessAsync(Arg.Any(), + Arg.Any()); return Task.CompletedTask; } @@ -113,32 +111,30 @@ public Task StatusIsDraftWithTokenSyncShouldNotSendTaskSuccess() TestHelpers.LoadDynamoDbEventSource( "./events/StreamEvents/contract_status_draft_waiting_for_approval.json"); - var retContractStatusItem = new ContractStatusItem - { - PropertyId = "usa/anytown/main-street/999", - ContractId = Guid.NewGuid(), - ContractStatus = "DRAFT", - ContractLastModifiedOn = DateTime.Today, - SfnWaitApprovedTaskToken = Token - }; - - var mockDynamoDbContext = new Mock(); - mockDynamoDbContext - .Setup(x => x.LoadAsync(It.IsAny(), CancellationToken.None).Result) - .Returns(retContractStatusItem); + var mockDynamoDbContext = Substitute.For(); + + mockDynamoDbContext.LoadAsync(Arg.Any(), CancellationToken.None) + .Returns(new ContractStatusItem + { + PropertyId = "usa/anytown/main-street/999", + ContractId = Guid.NewGuid(), + ContractStatus = "DRAFT", + ContractLastModifiedOn = DateTime.Today, + SfnWaitApprovedTaskToken = Token + }); - var mockStepFunctionsClient = new Mock(); + var mockStepFunctionsClient = Substitute.ForPartsOf(); var context = TestHelpers.NewLambdaContext(); var function = - new PropertiesApprovalSyncFunction(mockStepFunctionsClient.Object, mockDynamoDbContext.Object); + new PropertiesApprovalSyncFunction(mockStepFunctionsClient, mockDynamoDbContext); var handler = function.FunctionHandler(ddbEvent, context); - mockStepFunctionsClient.Verify( - client => client.SendTaskSuccessAsync(It.IsAny(), - It.IsAny()), Times.Never); + mockStepFunctionsClient.Received(0). + SendTaskSuccessAsync(Arg.Any(), + Arg.Any()); return Task.CompletedTask; } @@ -151,31 +147,27 @@ public Task StatusIsApprovedWithTokenSyncShouldSendTaskSuccess() TestHelpers.LoadDynamoDbEventSource( "./events/StreamEvents/contract_status_changed_approved_waiting_for_approval.json"); - var retContractStatusItem = new ContractStatusItem - { - PropertyId = "usa/anytown/main-street/999", - ContractId = Guid.NewGuid(), - ContractStatus = "APPROVED", - ContractLastModifiedOn = DateTime.Today, - SfnWaitApprovedTaskToken = Token - }; - - var mockStepFunctionsClient = new Mock(); - var mockDynamoDbContext = new Mock(); - mockDynamoDbContext - .Setup(x => - x.LoadAsync(It.IsAny(), - CancellationToken.None).Result) - .Returns(retContractStatusItem); + var mockStepFunctionsClient = Substitute.ForPartsOf(); + var mockDynamoDbContext = Substitute.For(); + + mockDynamoDbContext.LoadAsync(Arg.Any(), Arg.Is(CancellationToken.None)) + .Returns(new ContractStatusItem + { + PropertyId = "usa/anytown/main-street/999", + ContractId = Guid.NewGuid(), + ContractStatus = "APPROVED", + ContractLastModifiedOn = DateTime.Today, + SfnWaitApprovedTaskToken = Token + }); var context = TestHelpers.NewLambdaContext(); var function = - new PropertiesApprovalSyncFunction(mockStepFunctionsClient.Object, mockDynamoDbContext.Object); + new PropertiesApprovalSyncFunction(mockStepFunctionsClient, mockDynamoDbContext); var handler = function.FunctionHandler(ddbEvent, context); - mockStepFunctionsClient.Verify( - client => client.SendTaskSuccessAsync(It.IsAny(), - It.IsAny()), Times.Once); + mockStepFunctionsClient.Received(1). + SendTaskSuccessAsync(Arg.Any(), + Arg.Any()); return Task.CompletedTask; } diff --git a/Unicorn.Properties/PropertiesService.Tests/PropertiesService.Tests.csproj b/Unicorn.Properties/PropertiesService.Tests/PropertiesService.Tests.csproj index 670f14d..55a9137 100755 --- a/Unicorn.Properties/PropertiesService.Tests/PropertiesService.Tests.csproj +++ b/Unicorn.Properties/PropertiesService.Tests/PropertiesService.Tests.csproj @@ -8,9 +8,13 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Unicorn.Properties/PropertiesService/PropertiesService.csproj b/Unicorn.Properties/PropertiesService/PropertiesService.csproj index 3200b9a..103ff39 100755 --- a/Unicorn.Properties/PropertiesService/PropertiesService.csproj +++ b/Unicorn.Properties/PropertiesService/PropertiesService.csproj @@ -24,8 +24,8 @@ - - + + \ No newline at end of file diff --git a/Unicorn.Web/ApprovalService.Tests/ApprovalService.Tests.csproj b/Unicorn.Web/ApprovalService.Tests/ApprovalService.Tests.csproj index c34a685..df105e4 100644 --- a/Unicorn.Web/ApprovalService.Tests/ApprovalService.Tests.csproj +++ b/Unicorn.Web/ApprovalService.Tests/ApprovalService.Tests.csproj @@ -14,11 +14,11 @@ - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Unicorn.Web/ApprovalService.Tests/RequestApprovalFunctionTest.cs b/Unicorn.Web/ApprovalService.Tests/RequestApprovalFunctionTest.cs index 7102b52..a93b1ec 100644 --- a/Unicorn.Web/ApprovalService.Tests/RequestApprovalFunctionTest.cs +++ b/Unicorn.Web/ApprovalService.Tests/RequestApprovalFunctionTest.cs @@ -7,7 +7,7 @@ using Amazon.EventBridge; using Amazon.EventBridge.Model; using Amazon.Lambda.APIGatewayEvents; -using Moq; +using NSubstitute; using Unicorn.Web.Common; using Xunit; @@ -29,8 +29,8 @@ public async Task RequestApprovalFunction_WhenPropertyFound_SendsApprovalRequest var request = TestHelpers.LoadApiGatewayProxyRequest("./events/request_approval_event.json"); var context = TestHelpers.NewLambdaContext(); - var dynamoDbContext = new Mock(); - var eventBindingClient = new Mock(); + var dynamoDbContext = Substitute.For(); + var eventBindingClient = Substitute.For(); var searchResult = new List { @@ -45,17 +45,15 @@ public async Task RequestApprovalFunction_WhenPropertyFound_SendsApprovalRequest } }; - dynamoDbContext.Setup(c => - c.FromQueryAsync(It.IsAny(), It.IsAny())) + dynamoDbContext.FromQueryAsync(Arg.Any(), Arg.Any()) .Returns(TestHelpers.NewDynamoDBSearchResult(searchResult)); // dynamoDbContext.Setup(c => - // c.SaveAsync(It.IsAny(), It.IsAny()).ConfigureAwait(false)) + // c.SaveAsync(Arg.Any(), Arg.Any()).ConfigureAwait(false)) // .Returns(new ConfiguredTaskAwaitable()); - eventBindingClient.Setup(c => - c.PutEventsAsync(It.IsAny(), It.IsAny())) - .ReturnsAsync(new PutEventsResponse { FailedEntryCount = 0 }); + eventBindingClient.PutEventsAsync(Arg.Any(), Arg.Any()) + .Returns(new PutEventsResponse { FailedEntryCount = 0 }); var expectedResponse = new APIGatewayProxyResponse { @@ -68,25 +66,22 @@ public async Task RequestApprovalFunction_WhenPropertyFound_SendsApprovalRequest }; // Act - var function = new RequestApprovalFunction(dynamoDbContext.Object, eventBindingClient.Object); + var function = new RequestApprovalFunction(dynamoDbContext, eventBindingClient); var response = await function.FunctionHandler(request, context); // Assert Assert.Equal(expectedResponse.Headers, response.Headers); Assert.Equal(expectedResponse.StatusCode, response.StatusCode); - dynamoDbContext.Verify(v => - v.FromQueryAsync(It.IsAny(), It.IsAny()), - Times.Once); + dynamoDbContext.Received(1) + .FromQueryAsync(Arg.Any(), Arg.Any()); - dynamoDbContext.Verify(v => - v.SaveAsync(It.Is(p => p.Status == PropertyStatus.Pending), - It.IsAny()), - Times.Once); + await dynamoDbContext.Received(1) + .SaveAsync(Arg.Is(p => p.Status == PropertyStatus.Pending), + Arg.Any()); - eventBindingClient.Verify(v => - v.PutEventsAsync(It.Is(r=> r.Entries.First().DetailType == "PublicationApprovalRequested"), - It.IsAny()), - Times.Once); + await eventBindingClient.Received(1) + .PutEventsAsync(Arg.Is(r=> r.Entries.First().DetailType == "PublicationApprovalRequested"), + Arg.Any()); } } \ No newline at end of file diff --git a/Unicorn.Web/ApprovalService/ApprovalService.csproj b/Unicorn.Web/ApprovalService/ApprovalService.csproj index 6b267bd..44f71a4 100644 --- a/Unicorn.Web/ApprovalService/ApprovalService.csproj +++ b/Unicorn.Web/ApprovalService/ApprovalService.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/Unicorn.Web/ApprovalService/RequestApprovalRequest.cs b/Unicorn.Web/ApprovalService/RequestApprovalRequest.cs index a0879fc..c688d3d 100644 --- a/Unicorn.Web/ApprovalService/RequestApprovalRequest.cs +++ b/Unicorn.Web/ApprovalService/RequestApprovalRequest.cs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT-0 using System.Text.Json.Serialization; -using Unicorn.Web.Common; namespace Unicorn.Web.ApprovalService; diff --git a/Unicorn.Web/Common/Common.csproj b/Unicorn.Web/Common/Common.csproj index 6fbf201..9a4fb0a 100644 --- a/Unicorn.Web/Common/Common.csproj +++ b/Unicorn.Web/Common/Common.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/Unicorn.Web/SearchService.Tests/PropertySearchFunctionTest.cs b/Unicorn.Web/SearchService.Tests/PropertySearchFunctionTest.cs index f5ab58a..1d08da4 100644 --- a/Unicorn.Web/SearchService.Tests/PropertySearchFunctionTest.cs +++ b/Unicorn.Web/SearchService.Tests/PropertySearchFunctionTest.cs @@ -6,7 +6,7 @@ using Amazon.DynamoDBv2.DataModel; using Amazon.DynamoDBv2.DocumentModel; using Amazon.Lambda.APIGatewayEvents; -using Moq; +using NSubstitute; using Unicorn.Web.Common; using Xunit; @@ -44,9 +44,8 @@ public async Task PropertySearchFunction_SearchByStreet_ReturnsResults() } }; - var mockDynamoDbContext = new Mock(); - mockDynamoDbContext.Setup(c => - c.FromQueryAsync(It.IsAny(), It.IsAny())) + var mockDynamoDbContext = Substitute.For(); + mockDynamoDbContext.FromQueryAsync(Arg.Any(), Arg.Any()) .Returns(TestHelpers.NewDynamoDBSearchResult(searchResult)); var expectedResponse = new APIGatewayProxyResponse @@ -60,7 +59,7 @@ public async Task PropertySearchFunction_SearchByStreet_ReturnsResults() }; // Act - var function = new PropertySearchFunction(mockDynamoDbContext.Object); + var function = new PropertySearchFunction(mockDynamoDbContext); var response = await function.FunctionHandler(request, context); // Assert @@ -68,9 +67,8 @@ public async Task PropertySearchFunction_SearchByStreet_ReturnsResults() Assert.Equal(expectedResponse.StatusCode, response.StatusCode); Assert.NotEmpty(response.Body); - mockDynamoDbContext.Verify(v => - v.FromQueryAsync(It.IsAny(), It.IsAny()), - Times.Once); + mockDynamoDbContext.Received(1) + .FromQueryAsync(Arg.Any(), Arg.Any()); var items = JsonSerializer.Deserialize>(response.Body); Assert.NotNull(items); diff --git a/Unicorn.Web/SearchService.Tests/SearchService.Tests.csproj b/Unicorn.Web/SearchService.Tests/SearchService.Tests.csproj index f950d2b..ce85d7d 100644 --- a/Unicorn.Web/SearchService.Tests/SearchService.Tests.csproj +++ b/Unicorn.Web/SearchService.Tests/SearchService.Tests.csproj @@ -12,11 +12,11 @@ - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Unicorn.Web/SearchService/SearchService.csproj b/Unicorn.Web/SearchService/SearchService.csproj index 3a95131..f210e9d 100644 --- a/Unicorn.Web/SearchService/SearchService.csproj +++ b/Unicorn.Web/SearchService/SearchService.csproj @@ -16,7 +16,7 @@ - +