Refactor to eliminate unneeded BasketQueryService

This commit is contained in:
Steve Smith
2021-12-02 16:04:30 -05:00
parent 6f5a6c0860
commit 833dc3bd3a
11 changed files with 69 additions and 65 deletions

View File

@@ -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));
}
}
}

View File

@@ -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);
}
}