Allow to remove items from the basket setting quantity to zero
This commit is contained in:
@@ -53,5 +53,15 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(1, firstItem.Quantity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveEmptyItems()
|
||||
{
|
||||
var basket = new Basket();
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, 0);
|
||||
basket.RemoveEmptyItems();
|
||||
|
||||
Assert.Equal(0, basket.Items.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Moq;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTests
|
||||
{
|
||||
public class SetQuantities
|
||||
{
|
||||
private int _invalidId = -1;
|
||||
private Mock<IAsyncRepository<Basket>> _mockBasketRepo;
|
||||
private readonly int _invalidId = -1;
|
||||
private readonly Mock<IAsyncRepository<Basket>> _mockBasketRepo;
|
||||
|
||||
public SetQuantities()
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void ThrowsGivenInvalidBasketId()
|
||||
public async Task ThrowsGivenInvalidBasketId()
|
||||
{
|
||||
var basketService = new BasketService(_mockBasketRepo.Object, null);
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void ThrowsGivenNullQuantities()
|
||||
public async Task ThrowsGivenNullQuantities()
|
||||
{
|
||||
var basketService = new BasketService(null, null);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Services;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTests
|
||||
@@ -7,7 +8,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
||||
public class TransferBasket
|
||||
{
|
||||
[Fact]
|
||||
public async void ThrowsGivenNullAnonymousId()
|
||||
public async Task ThrowsGivenNullAnonymousId()
|
||||
{
|
||||
var basketService = new BasketService(null, null);
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Services.BasketServiceTes
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void ThrowsGivenNullUserId()
|
||||
public async Task ThrowsGivenNullUserId()
|
||||
{
|
||||
var basketService = new BasketService(null, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user