Files
eShopOnWeb/tests/UnitTests/Builders/OrderBuilder.cs
Shady Nagy 9db2feb930 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.
2021-11-05 19:55:48 -04:00

48 lines
1.4 KiB
C#

using System.Collections.Generic;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.UnitTests.Builders;
public class OrderBuilder
{
private Order _order;
public string TestBuyerId => "12345";
public int TestCatalogItemId => 234;
public string TestProductName => "Test Product Name";
public string TestPictureUri => "http://test.com/image.jpg";
public decimal TestUnitPrice = 1.23m;
public int TestUnits = 3;
public CatalogItemOrdered TestCatalogItemOrdered { get; }
public OrderBuilder()
{
TestCatalogItemOrdered = new CatalogItemOrdered(TestCatalogItemId, TestProductName, TestPictureUri);
_order = WithDefaultValues();
}
public Order Build()
{
return _order;
}
public Order WithDefaultValues()
{
var orderItem = new OrderItem(TestCatalogItemOrdered, TestUnitPrice, TestUnits);
var itemList = new List<OrderItem>() { orderItem };
_order = new Order(TestBuyerId, new AddressBuilder().WithDefaultValues(), itemList);
return _order;
}
public Order WithNoItems()
{
_order = new Order(TestBuyerId, new AddressBuilder().WithDefaultValues(), new List<OrderItem>());
return _order;
}
public Order WithItems(List<OrderItem> items)
{
_order = new Order(TestBuyerId, new AddressBuilder().WithDefaultValues(), items);
return _order;
}
}