Updated Unit tests after recent changes (#409)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||||
using Microsoft.eShopWeb.ApplicationCore.Services;
|
using Microsoft.eShopWeb.ApplicationCore.Services;
|
||||||
|
using Microsoft.eShopWeb.ApplicationCore.Specifications;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@@ -22,13 +23,13 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
|||||||
{
|
{
|
||||||
var basket = new Basket(_buyerId);
|
var basket = new Basket(_buyerId);
|
||||||
basket.AddItem(1, It.IsAny<decimal>(), It.IsAny<int>());
|
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);
|
var basketService = new BasketService(_mockBasketRepo.Object, null);
|
||||||
|
|
||||||
await basketService.AddItemToBasket(basket.Id, 1, 1.50m);
|
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]
|
[Fact]
|
||||||
@@ -36,7 +37,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
|||||||
{
|
{
|
||||||
var basket = new Basket(_buyerId);
|
var basket = new Basket(_buyerId);
|
||||||
basket.AddItem(1, It.IsAny<decimal>(), It.IsAny<int>());
|
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);
|
var basketService = new BasketService(_mockBasketRepo.Object, null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user