Refactor to eliminate unneeded BasketQueryService
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Xunit;
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests;
|
||||
|
||||
public class BasketAddItem
|
||||
@@ -72,4 +72,4 @@ public class BasketAddItem
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => basket.AddItem(_testCatalogItemId, _testUnitPrice, -2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests;
|
||||
|
||||
public class BasketTotalItems
|
||||
{
|
||||
private readonly int _testCatalogItemId = 123;
|
||||
private readonly decimal _testUnitPrice = 1.23m;
|
||||
private readonly int _testQuantity = 2;
|
||||
private readonly string _buyerId = "Test buyerId";
|
||||
|
||||
[Fact]
|
||||
public void ReturnsTotalQuantityWithOneItem()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
|
||||
var result = basket.TotalItems;
|
||||
|
||||
Assert.Equal(_testQuantity, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsTotalQuantityWithMultipleItems()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity*2);
|
||||
|
||||
var result = basket.TotalItems;
|
||||
|
||||
Assert.Equal(_testQuantity*3, result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user