MicrosoftLearning / AZ400-DesigningandImplementingMicrosoftDevOpsSolutions

AZ-400 Course Repository for Labs and Demos.
https://microsoftlearning.github.io/AZ400-DesigningandImplementingMicrosoftDevOpsSolutions/
MIT License
540 stars 1k forks source link

M05-L11 Fix eShopOnWeb repo unit test #504

Closed rmajid2 closed 7 months ago

rmajid2 commented 1 year ago

Contact Details

No response

What happened?

Exercise : 01 Task: 01 Step: 07

Description of issue:

Pipeline run fail as unit test ci task fire exeption

Failed Microsoft.eShopWeb.UnitTests.MediatorHandlers.OrdersTests.GetOrderDetails.NotBeNullIfOrderExists [80 ms] Error Message: Assert.NotNull() Failure Stack Trace: at Microsoft.eShopWeb.UnitTests.MediatorHandlers.OrdersTests.GetOrderDetails.NotBeNullIfOrderExists() in /home/vsts/work/1/s/tests/UnitTests/MediatorHandlers/OrdersTests/GetOrderDetails.cs:line 38 --- End of stack trace from previous location --- Failed Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTests.AddItemToBasket.InvokesBasketRepositoryUpdateAsyncOnce [239 ms] Error Message: Moq.MockException : Expected invocation on the mock once, but was 0 times: x => x.UpdateAsync(Basket, CancellationToken)

image

Quickly verifying the source code of imported project, I find that the mock of unit test is for "GetBySpecAsync"

image

but a recent commit to the project changed the tested method to use "FirstOrDefaultAsync"

image

Repro steps: Run the created pipeline

Lab

Enable Dynamic Configuration and Feature Flags

Relevant screenshots

No response

Do you want to help us? 👏

LuizMacedo commented 7 months ago

Thanks @rmajid2, PR https://github.com/MicrosoftLearning/eShopOnWeb/pull/82 will be fixing the issue in eShopOnWeb repo.