Shady nagy/net6 (#614)
* udated to .net6 * used the .net6 version RC2 * added editconfig. * App core new Scoped Namespaces style. * BlazorAdmin new Scoped Namespaces style. * Blazor Shared new Scoped Namespaces style. * Infra new Scoped Namespaces style. * public api new Scoped Namespaces style. * web new Scoped Namespaces style. * FunctionalTests new Scoped Namespaces style. * Integrational tests new Scoped Namespaces style. * unit tests new Scoped Namespaces style. * update github action. * update github action. * change the global.
This commit is contained in:
@@ -1,76 +1,75 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests
|
||||
{
|
||||
public class BasketAddItem
|
||||
{
|
||||
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 AddsBasketItemIfNotPresent()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testCatalogItemId, firstItem.CatalogItemId);
|
||||
Assert.Equal(_testUnitPrice, firstItem.UnitPrice);
|
||||
Assert.Equal(_testQuantity, firstItem.Quantity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncrementsQuantityOfItemIfPresent()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testQuantity * 2, firstItem.Quantity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepsOriginalUnitPriceIfMoreItemsAdded()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice * 2, _testQuantity);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testUnitPrice, firstItem.UnitPrice);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultsToQuantityOfOne()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(1, firstItem.Quantity);
|
||||
}
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests;
|
||||
|
||||
[Fact]
|
||||
public void CantAddItemWithNegativeQuantity()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
public class BasketAddItem
|
||||
{
|
||||
private readonly int _testCatalogItemId = 123;
|
||||
private readonly decimal _testUnitPrice = 1.23m;
|
||||
private readonly int _testQuantity = 2;
|
||||
private readonly string _buyerId = "Test buyerId";
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => basket.AddItem(_testCatalogItemId, _testUnitPrice, -1));
|
||||
}
|
||||
[Fact]
|
||||
public void AddsBasketItemIfNotPresent()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
|
||||
[Fact]
|
||||
public void CantModifyQuantityToNegativeNumber()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice);
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testCatalogItemId, firstItem.CatalogItemId);
|
||||
Assert.Equal(_testUnitPrice, firstItem.UnitPrice);
|
||||
Assert.Equal(_testQuantity, firstItem.Quantity);
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => basket.AddItem(_testCatalogItemId, _testUnitPrice, -2));
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void IncrementsQuantityOfItemIfPresent()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testQuantity * 2, firstItem.Quantity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepsOriginalUnitPriceIfMoreItemsAdded()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, _testQuantity);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice * 2, _testQuantity);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(_testUnitPrice, firstItem.UnitPrice);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultsToQuantityOfOne()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice);
|
||||
|
||||
var firstItem = basket.Items.Single();
|
||||
Assert.Equal(1, firstItem.Quantity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CantAddItemWithNegativeQuantity()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => basket.AddItem(_testCatalogItemId, _testUnitPrice, -1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CantModifyQuantityToNegativeNumber()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => basket.AddItem(_testCatalogItemId, _testUnitPrice, -2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.BasketTests;
|
||||
|
||||
public class BasketRemoveEmptyItems
|
||||
{
|
||||
public class BasketRemoveEmptyItems
|
||||
private readonly int _testCatalogItemId = 123;
|
||||
private readonly decimal _testUnitPrice = 1.23m;
|
||||
private readonly string _buyerId = "Test buyerId";
|
||||
|
||||
[Fact]
|
||||
public void RemovesEmptyBasketItems()
|
||||
{
|
||||
private readonly int _testCatalogItemId = 123;
|
||||
private readonly decimal _testUnitPrice = 1.23m;
|
||||
private readonly string _buyerId = "Test buyerId";
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, 0);
|
||||
basket.RemoveEmptyItems();
|
||||
|
||||
[Fact]
|
||||
public void RemovesEmptyBasketItems()
|
||||
{
|
||||
var basket = new Basket(_buyerId);
|
||||
basket.AddItem(_testCatalogItemId, _testUnitPrice, 0);
|
||||
basket.RemoveEmptyItems();
|
||||
|
||||
Assert.Equal(0, basket.Items.Count);
|
||||
}
|
||||
Assert.Equal(0, basket.Items.Count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,55 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.CatalogItemTests
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.CatalogItemTests;
|
||||
|
||||
public class UpdateDetails
|
||||
{
|
||||
public class UpdateDetails
|
||||
private CatalogItem _testItem;
|
||||
private int _validTypeId = 1;
|
||||
private int _validBrandId = 2;
|
||||
private string _validDescription = "test description";
|
||||
private string _validName = "test name";
|
||||
private decimal _validPrice = 1.23m;
|
||||
private string _validUri = "/123";
|
||||
|
||||
public UpdateDetails()
|
||||
{
|
||||
private CatalogItem _testItem;
|
||||
private int _validTypeId = 1;
|
||||
private int _validBrandId = 2;
|
||||
private string _validDescription = "test description";
|
||||
private string _validName = "test name";
|
||||
private decimal _validPrice = 1.23m;
|
||||
private string _validUri = "/123";
|
||||
_testItem = new CatalogItem(_validTypeId, _validBrandId, _validDescription, _validName, _validPrice, _validUri);
|
||||
}
|
||||
|
||||
public UpdateDetails()
|
||||
{
|
||||
_testItem = new CatalogItem(_validTypeId, _validBrandId, _validDescription, _validName, _validPrice, _validUri);
|
||||
}
|
||||
[Fact]
|
||||
public void ThrowsArgumentExceptionGivenEmptyName()
|
||||
{
|
||||
string newValue = "";
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(newValue, _validDescription, _validPrice));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsArgumentExceptionGivenEmptyName()
|
||||
{
|
||||
string newValue = "";
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(newValue, _validDescription, _validPrice));
|
||||
}
|
||||
[Fact]
|
||||
public void ThrowsArgumentExceptionGivenEmptyDescription()
|
||||
{
|
||||
string newValue = "";
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(_validName, newValue, _validPrice));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsArgumentExceptionGivenEmptyDescription()
|
||||
{
|
||||
string newValue = "";
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(_validName, newValue, _validPrice));
|
||||
}
|
||||
[Fact]
|
||||
public void ThrowsArgumentNullExceptionGivenNullName()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _testItem.UpdateDetails(null, _validDescription, _validPrice));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsArgumentNullExceptionGivenNullName()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _testItem.UpdateDetails(null, _validDescription, _validPrice));
|
||||
}
|
||||
[Fact]
|
||||
public void ThrowsArgumentNullExceptionGivenNullDescription()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _testItem.UpdateDetails(_validName, null, _validPrice));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsArgumentNullExceptionGivenNullDescription()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _testItem.UpdateDetails(_validName, null, _validPrice));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(-1.23)]
|
||||
public void ThrowsArgumentExceptionGivenNonPositivePrice(decimal newPrice)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(_validName, _validDescription, newPrice));
|
||||
}
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(-1.23)]
|
||||
public void ThrowsArgumentExceptionGivenNonPositivePrice(decimal newPrice)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _testItem.UpdateDetails(_validName, _validDescription, newPrice));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,40 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
|
||||
using Microsoft.eShopWeb.UnitTests.Builders;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.OrderTests
|
||||
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Entities.OrderTests;
|
||||
|
||||
public class OrderTotal
|
||||
{
|
||||
public class OrderTotal
|
||||
private decimal _testUnitPrice = 42m;
|
||||
|
||||
[Fact]
|
||||
public void IsZeroForNewOrder()
|
||||
{
|
||||
private decimal _testUnitPrice = 42m;
|
||||
var order = new OrderBuilder().WithNoItems();
|
||||
|
||||
[Fact]
|
||||
public void IsZeroForNewOrder()
|
||||
{
|
||||
var order = new OrderBuilder().WithNoItems();
|
||||
Assert.Equal(0, order.Total());
|
||||
}
|
||||
|
||||
Assert.Equal(0, order.Total());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsCorrectGiven1Item()
|
||||
{
|
||||
var builder = new OrderBuilder();
|
||||
var items = new List<OrderItem>
|
||||
[Fact]
|
||||
public void IsCorrectGiven1Item()
|
||||
{
|
||||
var builder = new OrderBuilder();
|
||||
var items = new List<OrderItem>
|
||||
{
|
||||
new OrderItem(builder.TestCatalogItemOrdered, _testUnitPrice, 1)
|
||||
};
|
||||
var order = new OrderBuilder().WithItems(items);
|
||||
Assert.Equal(_testUnitPrice, order.Total());
|
||||
}
|
||||
var order = new OrderBuilder().WithItems(items);
|
||||
Assert.Equal(_testUnitPrice, order.Total());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsCorrectGiven3Items()
|
||||
{
|
||||
var builder = new OrderBuilder();
|
||||
var order = builder.WithDefaultValues();
|
||||
[Fact]
|
||||
public void IsCorrectGiven3Items()
|
||||
{
|
||||
var builder = new OrderBuilder();
|
||||
var order = builder.WithDefaultValues();
|
||||
|
||||
Assert.Equal(builder.TestUnitPrice * builder.TestUnits, order.Total());
|
||||
}
|
||||
Assert.Equal(builder.TestUnitPrice * builder.TestUnits, order.Total());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user