Adding Tests and Refactoring
Functional Tests for RazorPages added
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using ApplicationCore.Interfaces;
|
||||
using Ardalis.GuardClauses;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ApplicationCore.Entities.BuyerAggregate
|
||||
{
|
||||
@@ -14,13 +13,15 @@ namespace ApplicationCore.Entities.BuyerAggregate
|
||||
|
||||
public IEnumerable<PaymentMethod> PaymentMethods => _paymentMethods.AsReadOnly();
|
||||
|
||||
protected Buyer()
|
||||
private Buyer()
|
||||
{
|
||||
// required by EF
|
||||
}
|
||||
|
||||
public Buyer(string identity) : this()
|
||||
{
|
||||
IdentityGuid = !string.IsNullOrWhiteSpace(identity) ? identity : throw new ArgumentNullException(nameof(identity));
|
||||
Guard.Against.NullOrEmpty(identity, nameof(identity));
|
||||
IdentityGuid = identity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ApplicationCore.Entities.OrderAggregate
|
||||
{
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
namespace ApplicationCore.Entities.OrderAggregate
|
||||
using Ardalis.GuardClauses;
|
||||
|
||||
namespace ApplicationCore.Entities.OrderAggregate
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the item that was ordered. If catalog item details change, details of
|
||||
/// Represents a snapshot of the item that was ordered. If catalog item details change, details of
|
||||
/// the item that was part of a completed order should not change.
|
||||
/// </summary>
|
||||
public class CatalogItemOrdered // ValueObject
|
||||
{
|
||||
public CatalogItemOrdered(int catalogItemId, string productName, string pictureUri)
|
||||
{
|
||||
Guard.Against.OutOfRange(catalogItemId, nameof(catalogItemId), 1, int.MaxValue);
|
||||
Guard.Against.NullOrEmpty(productName, nameof(productName));
|
||||
Guard.Against.NullOrEmpty(pictureUri, nameof(pictureUri));
|
||||
|
||||
CatalogItemId = catalogItemId;
|
||||
ProductName = productName;
|
||||
PictureUri = pictureUri;
|
||||
}
|
||||
|
||||
private CatalogItemOrdered()
|
||||
{
|
||||
// required by EF
|
||||
}
|
||||
|
||||
public int CatalogItemId { get; private set; }
|
||||
public string ProductName { get; private set; }
|
||||
public string PictureUri { get; private set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ApplicationCore.Interfaces;
|
||||
using Ardalis.GuardClauses;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,13 +10,18 @@ namespace ApplicationCore.Entities.OrderAggregate
|
||||
{
|
||||
private Order()
|
||||
{
|
||||
// required by EF
|
||||
}
|
||||
|
||||
public Order(string buyerId, Address shipToAddress, List<OrderItem> items)
|
||||
{
|
||||
Guard.Against.NullOrEmpty(buyerId, nameof(buyerId));
|
||||
Guard.Against.Null(shipToAddress, nameof(shipToAddress));
|
||||
Guard.Against.Null(items, nameof(items));
|
||||
|
||||
BuyerId = buyerId;
|
||||
ShipToAddress = shipToAddress;
|
||||
_orderItems = items;
|
||||
BuyerId = buyerId;
|
||||
}
|
||||
public string BuyerId { get; private set; }
|
||||
|
||||
@@ -43,6 +49,5 @@ namespace ApplicationCore.Entities.OrderAggregate
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ namespace ApplicationCore.Entities.OrderAggregate
|
||||
public decimal UnitPrice { get; private set; }
|
||||
public int Units { get; private set; }
|
||||
|
||||
protected OrderItem()
|
||||
private OrderItem()
|
||||
{
|
||||
// required by EF
|
||||
}
|
||||
|
||||
public OrderItem(CatalogItemOrdered itemOrdered, decimal unitPrice, int units)
|
||||
{
|
||||
ItemOrdered = itemOrdered;
|
||||
|
||||
Reference in New Issue
Block a user