Skip to content

Commit

Permalink
Updated Unit tests after recent changes (dotnet-architecture#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
efleming18 authored Jun 22, 2020
1 parent 5c0f7fa commit a4d02d9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Services;
using Microsoft.eShopWeb.ApplicationCore.Specifications;
using Moq;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -22,21 +23,21 @@ public async Task InvokesBasketRepositoryGetByIdAsyncOnce()
{
var basket = new Basket(_buyerId);
basket.AddItem(1, It.IsAny<decimal>(), It.IsAny<int>());
_mockBasketRepo.Setup(x => x.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(basket);
_mockBasketRepo.Setup(x => x.FirstOrDefaultAsync(It.IsAny<BasketWithItemsSpecification>())).ReturnsAsync(basket);

var basketService = new BasketService(_mockBasketRepo.Object, null);

await basketService.AddItemToBasket(basket.Id, 1, 1.50m);

_mockBasketRepo.Verify(x => x.GetByIdAsync(It.IsAny<int>()), Times.Once);
_mockBasketRepo.Verify(x => x.FirstOrDefaultAsync(It.IsAny<BasketWithItemsSpecification>()), Times.Once);
}

[Fact]
public async Task InvokesBasketRepositoryUpdateAsyncOnce()
{
var basket = new Basket(_buyerId);
basket.AddItem(1, It.IsAny<decimal>(), It.IsAny<int>());
_mockBasketRepo.Setup(x => x.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(basket);
_mockBasketRepo.Setup(x => x.FirstOrDefaultAsync(It.IsAny<BasketWithItemsSpecification>())).ReturnsAsync(basket);

var basketService = new BasketService(_mockBasketRepo.Object, null);

Expand Down

0 comments on commit a4d02d9

Please sign in to comment.