Refactoring and Adding Tests (#58)

* Moving Identity seeding to its own class and method.

* Adding tests for AddItem

* Added catalog api controller and functional tests
Added and cleaned up some comments

* Adding integration tests for OrderRepository

* Getting integration test for order working with inmemory db
This commit is contained in:
Steve Smith
2017-10-20 12:52:42 -04:00
committed by GitHub
parent 32950aa175
commit 0eb4d72b89
17 changed files with 306 additions and 94 deletions

View File

@@ -0,0 +1,28 @@
using ApplicationCore.Entities.OrderAggregate;
namespace UnitTests.Builders
{
public class AddressBuilder
{
private Address _address;
public string TestStreet => "123 Main St.";
public string TestCity => "Kent";
public string TestState => "OH";
public string TestCountry => "USA";
public string TestZipCode => "44240";
public AddressBuilder()
{
_address = WithDefaultValues();
}
public Address Build()
{
return _address;
}
public Address WithDefaultValues()
{
_address = new Address(TestStreet, TestCity, TestState, TestCountry, TestZipCode);
return _address;
}
}
}

View File

@@ -0,0 +1,38 @@
using ApplicationCore.Entities.OrderAggregate;
using System;
using System.Collections.Generic;
using System.Text;
namespace 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;
}
}
}