INVENTORY
using [Link];
using ICT711_Day5_classes;
using System;
using [Link];
using [Link];
using [Link];
namespace ICT711_Day5_classes.Tests
{
[TestClass()]
public class InventoryTests
{
[TestMethod()]
public void AddProductTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Test add product functionality
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
[Link](product1);
[Link](1, [Link]);
[Link](product2);
[Link](2, [Link]);
[Link](product3);
[Link](3, [Link]);
[Link](product4);
[Link](4, [Link]);
// Product already in inventory. Add quantity
[Link](product5);
[Link](4, [Link]);
[Link](16, [Link]);
[TestMethod()]
public void IndexProductIdTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Indexer with the product Id
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
IProduct expected = product3;
IProduct actual = inventory[24];
[Link](expected, actual);
[TestMethod()]
public void IndexProductNameTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Use part of the product name to retrieve a list of all matches
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
List<IProduct> expected = new List<IProduct>() { product1, product3 };
List<IProduct> actual = inventory["M Shirt"];
[Link]([Link], [Link]);
[Link](0, [Link](expected).Count());
[TestMethod()]
public void RemoveProductTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Remove product - happy path
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](11, inventory[25].Quantity);
// Product already in inventory. Subtract quantity
[Link](product5);
[Link](6, inventory[25].Quantity);
// Make sure the other products are not changed
[Link](78, inventory[22].Quantity);
[Link](12, inventory[23].Quantity);
[Link](10, inventory[24].Quantity);
[TestMethod()]
public void RemoveProductNotInInventoryTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Remove product not in inventory
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
string expected = "Product is not in inventory.";
string actual = "";
// Product is not in inventory. Exception
try { [Link](product4); }
catch (Exception e) { actual = [Link]; }
[Link](expected, actual);
[TestMethod()]
public void RemoveProductNotEnoughTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Try to remove more quantity than what we have in inventory
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product5);
string expected = "There is not enough quantity.";
string actual = "";
// Product is not in inventory. Exception
try { [Link](product4); }
catch (ArgumentOutOfRangeException e) { actual = [Link]; }
[Link](expected, [Link](0, [Link]));
[TestMethod()]
public void PlusOperatorTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Test add product functionality
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
inventory += product1;
[Link](1, [Link]);
inventory += (product2);
[Link](2, [Link]);
inventory += (product3);
[Link](3, [Link]);
inventory += (product4);
[Link](4, [Link]);
// Product already in inventory. Add quantity
inventory += (product5);
[Link](4, [Link]);
[Link](16, [Link]);
[TestMethod()]
public void MinusOperatorTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Remove product using "-" - happy path
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Product product5 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 5);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](11, inventory[25].Quantity);
// Product already in inventory. Subtract quantity
inventory -= (product5);
[Link](6, inventory[25].Quantity);
// Make sure the other products are not changed
[Link](78, inventory[22].Quantity);
[Link](12, inventory[23].Quantity);
[Link](10, inventory[24].Quantity);
[TestMethod()]
public void RemoveProductGarmentTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// You must do this test after we finish the Polymorphism and do the ProductGarment class
// Remove product - happy path
ProductGarment product1 = new ProductGarment(22, "Shirt", "Men Shirt");
[Link]("S", 10, 15.0m);
[Link]("M", 20, 20.0m);
[Link]("L", 5, 10.0m);
ProductGarment product2 = new ProductGarment(22, "Shirt", "Men Shirt");
[Link]("S", 2, 15.0m);
[Link]("M", 3, 20.0m);
[Link]("L", 5, 10.0m);
Inventory inventory = new Inventory();
[Link](product1);
[Link](10, ((ProductGarment)inventory[22]).SizePriceQuantity["S"].quantity);
// Product already in inventory. Subtract quantity
[Link](product2);
[Link](8, ((ProductGarment)inventory[22]).SizePriceQuantity["S"].quantity);
[Link](17, ((ProductGarment)inventory[22]).SizePriceQuantity["M"].quantity);
[Link](0, ((ProductGarment)inventory[22]).SizePriceQuantity["L"].quantity);
}
}
}
SALE
using [Link];
using ICT711_Day5_classes;
using System;
using [Link];
using [Link];
namespace ICT711_Day5_classes.Tests
{
[TestClass()]
public class SaleTests
{
[TestMethod()]
public void SaleConstructorTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// The Sale Id is non-negative integer
ISale sale = new Sale();
[Link]([Link], typeof(int));
[Link]([Link] >= 0);
[TestMethod()]
public void SaleConstructorParametrizedTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// The Sale Id is non negative integer
ISale sale = new Sale(4, 1, [Link]);
// Check Id
[Link]([Link], typeof(int));
[Link]([Link] >= 0);
[Link](4, [Link]); // CustomerId
[Link](1, [Link]); // AssociateId
[Link]([Link], [Link]); // Status
}
[TestMethod()]
public void SaleConstructorParametrizedWithIdTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// Set Sale Id
ISale sale = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
// Check Sale Id
[Link]([Link], typeof(int));
[Link]([Link] == 550);
[Link](0, new DateTime(2020, 10, 1).CompareTo([Link])); // Date
[Link](4, [Link]); // CustomerId
[Link](1, [Link]); // AssociateId
[Link]([Link], [Link]); // Status
[TestMethod()]
public void AddProductTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
ISale sale = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](new Product((Product)inventory[22]) { Quantity = 3 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
[Link](2, [Link]);
[Link](23, [Link][1].ProductId);
[Link](75, inventory[22].Quantity); // Make sure the sold quantity is deducted from inventory
[Link](10, inventory[23].Quantity); // Make sure the sold quantity is deducted from inventory
[TestMethod()]
public void GetTotalTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
ISale sale = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](new Product((Product)inventory[22]) { Quantity = 3 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
decimal expected = [Link] * 3 + [Link] * 2;
decimal actual = [Link]();
[Link](expected, actual);
[TestMethod()]
public void RemoveProductTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
ISale sale = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
Product product4 = new Product(25, "L Shirt S", "Ladies Shirt Small", 17.37m, 11);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](new Product((Product)inventory[22]) { Quantity = 3 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 1 }, inventory);
[Link](2, [Link]);
[Link](23, [Link][1].ProductId);
[Link](1, [Link][1].Quantity);
[Link](75, inventory[22].Quantity); // Make sure the sold quantity is deducted from inventory
[Link](11, inventory[23].Quantity); // Make sure the updated sold quantity is deducted from inventory
}
[TestMethod()]
public void RemoveProductGarmentTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
// You must do this test after we finish the Polymorphism and do the ProductGarment class
ISale sale = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
ProductGarment product3 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
[Link]("S", 10, 15.0m);
ProductGarment product4 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
[Link]("S", 30, 15.0m);
[Link]("L", 30, 41.0m);
Inventory inventory = new Inventory();
[Link](product4);
[Link](product3, inventory);
[Link](1, [Link]);
[Link](24, [Link][0].ProductId);
[Link](10, ((ProductGarment)[Link][0]).SizePriceQuantity["S"].quantity);
[Link](product3, inventory);
[Link](1, [Link]);
[Link](20, ((ProductGarment)[Link][0]).SizePriceQuantity["S"].quantity);
ProductGarment product5 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
[Link]("S", 5, 15.0m);
[Link](product5, inventory);
[Link](15, ((ProductGarment)[Link][0]).SizePriceQuantity["S"].quantity);
[Link](15, ((ProductGarment)inventory[24]).SizePriceQuantity["S"].quantity); // Make sure the
updated sold quantity is deducted from inventory
}
}
}
STORE
using [Link];
using ICT711_Day5_classes;
using System;
using [Link];
using [Link];
using [Link];
namespace ICT711_Day5_classes.Tests
[TestClass()]
public class StoreTests
[TestMethod()]
public void SaveAssociatesTest()
// After creating your class, Remove the next line and uncomment the below test code.
//[Link]();
IAssociate associate1 = (IAssociate)new Associate(1, "John", "Smith", "40300000", "[email protected]", "Manager", "Store
manager");
IAssociate associate2 = (IAssociate)new Associate(78, "Mike", "M", "40377777", "[email protected]", "Finance", "Finance
associate", 1);
IAssociate associate3 = (IAssociate)new Associate(4786, "Sam", "T", "40344444", "[email protected]", "Sales", "Store
sales", 1);
IAssociate associate4 = (IAssociate)new Associate(47851, "Jim", "W", "40388888", "[email protected]", "Marketing",
"Marketing associate", 1);
IStore store = new Store() { Associates = new List<IAssociate>() { associate1, associate2, associate3,
associate4 } };
[Link]();
int expected = 1155;
int actual = [Link]([Link]).Length;
[Link]([Link](expected - actual) < 10);
[TestMethod()]
public void SaveCustomersTest()
// After creating your class, Remove the next line and uncomment the below test code.
//[Link]();
Customer customer1 = new Customer(100, "John", "Smith", "40300000", "[email protected]");
Customer customer2 = new Customer(110, "Mike", "Todd", "40355555", "[email protected]");
Customer customer3 = new Customer(150, "Eddy", "Sam", "403777777", "[email protected]");
Customer customer4 = new Customer(177, "July", "Jack", "40399999", "[email protected]");
IStore store = new Store() { Customers = new List<ICustomer>() { customer1, customer2, customer3, customer4 }
};
[Link]();
int expected = 1125; // 1072
int actual = [Link]([Link]).Length;
[Link]([Link](expected - actual) < 10);
}
[TestMethod()]
public void SaveSalesTest()
// After creating your class, Remove the next line and uncomment the below test code.
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
ProductGarment product4 = new ProductGarment(25, "Ladies Shirt", "Ladies Shirt M1");
ProductGarment product5 = new ProductGarment(26, "L Shirt", "Ladies Shirt M2");
[Link]("S", 10, 15.0m);
[Link]("M", 20, 20.0m);
[Link]("S", 5, 15.0m);
[Link]("M", 7, 19.0m);
[Link]("S", 10, 15.0m);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](product5);
ISale sale1 = new Sale(550, new DateTime(2020, 10, 1), 4, 1, [Link]);
[Link](new Product((Product)inventory[22]) { Quantity = 3 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
[Link](new Product((Product)inventory[24]) { Quantity = 4 }, inventory);
ISale sale2 = new Sale(555, new DateTime(2020, 10, 10), 4, 1, [Link]);
[Link](new Product((Product)inventory[22]) { Quantity = 1 }, inventory);
[Link](new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
ProductGarment prod1 = (ProductGarment)((ProductGarment)inventory[25]).Clone();
[Link]();
[Link]("S", 2, 15.0m);
[Link]("M", 1, 20.0m);
[Link](prod1, inventory);
ProductGarment prod2 = (ProductGarment)((ProductGarment)inventory[26]).Clone();
[Link]();
[Link]("S", 3, 15.0m);
[Link]("M", 4, 19.0m);
[Link](prod2, inventory);
IStore store = new Store() { Sales = new List<ISale>() { sale1, sale2 } };
[Link]();
int expected = 2217;
int actual = [Link]([Link]).Length;
[Link]([Link](expected - actual) < 10);
[TestMethod()]
public void SaveInventoryTest()
// After creating your class, Remove the next line and uncomment the below test code.
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Product product2 = new Product(23, "L Shirt", "Ladies Shirt", 17.47m, 12);
Product product3 = new Product(24, "M Shirt S", "Men Shirt Small", 14.37m, 10);
ProductGarment product4 = new ProductGarment(25, "Ladies Shirt", "Ladies Shirt M1");
ProductGarment product5 = new ProductGarment(26, "L Shirt", "Ladies Shirt M2");
[Link]("S", 10, 15.0m);
[Link]("M", 20, 20.0m);
[Link]("S", 5, 15.0m);
[Link]("M", 7, 19.0m);
[Link]("S", 10, 15.0m);
Inventory inventory = new Inventory();
[Link](product1);
[Link](product2);
[Link](product3);
[Link](product4);
[Link](product5);
IStore store = new Store() { Inventory = inventory };
[Link]();
int expected = 1358;
int actual = [Link]([Link]).Length;
[Link]([Link](expected - actual) < 10);
[TestMethod()]
public void SaveStoreInfo()
// After creating your class, Remove the next line and uncomment the below test code.
Product product1 = new Product(22, "M Shirt", "Men Shirt", 14.47m, 78);
Inventory inventory = new Inventory();
[Link](product1);
IStore store = new Store() { Inventory = inventory, StoreName = "New Store Name", Address = "Somewhere
address" };
[Link] = new List<IAssociate>() { new Associate() { AssociateId = 2 } };
[Link] = new List<ICustomer>() { new Customer(100, "John", "Smith", "40300000", "[email protected]") };
[Link]();
string stringContents = [Link]([Link]);
[Link]([Link]("New Store Name"));
[Link]([Link]("Somewhere address"));
[Link](); // Should not include customer information
[Link](); // Should not include inventory information
[Link](); // Should not include Associates information
[Link](); // Should not include Sales information
[Link]([Link] < 500);
[TestMethod()]
public void LoadAssociatesTest()
// After creating your class, Remove the next line and uncomment the below test code.
//[Link]();
IStore store = new Store();
[Link]();
[Link](4, [Link]);
[Link](1, [Link][0].AssociateId);
[Link](78, [Link][1].AssociateId);
[Link]("Sam", [Link][2].FName);
[Link]("40388888", [Link][3].Tel);
[Link]("Marketing", [Link][3].Department);
[Link](1, [Link][2].ManagerId);
[TestMethod()]
public void LoadCustomersTest()
// After creating your class, Remove the next line and uncomment the below test code.
//[Link]();
IStore store = new Store();
[Link]();
[Link](4, [Link]);
[Link](100, [Link][0].CustomerId);
[Link](110, [Link][1].CustomerId);
[Link]("Eddy", [Link][2].FName);
[Link]("40399999", [Link][3].Tel);
[TestMethod()]
public void LoadSalesTest()
// After creating your class, Remove the next line and uncomment the below test code.
//[Link]();
IStore store = new Store();
[Link]();
[Link](2, [Link]);
[Link](4, [Link][0].CustomerId);
[Link](1, [Link][0].AssociateId);
[Link](3, [Link][0].[Link]);
[Link](4, [Link][1].[Link]);
[Link]("Men Shirt", [Link][1].ProductsList[0].Description);
[Link](17.47m, [Link][1].ProductsList[1].Price);
[Link]([Link][1].ProductsList[2], typeof(ProductGarment));
[TestMethod()]
public void LoadInventoryTest()
{
// After creating your class, Remove the next line and uncomment the below test code.
IStore store = new Store();
[Link]();
[Link](5, [Link]);
[Link]("Men Shirt", [Link][22].Description);
[Link]("Ladies Shirt", [Link][25].ProductName);
[Link](17.47m, [Link][23].Price);
[Link](10, [Link][24].Quantity);
[Link]([Link][25], typeof(ProductGarment));
[Link]([Link][26], typeof(ProductGarment));
[Link](2, ((ProductGarment)[Link][26]).[Link]);
[Link](358.0m, ((ProductGarment)[Link][26]).GetSubTotal());
[TestMethod()]
public void CreateStoreTest()
Store store = [Link]();
string Expect_StoreName = "New Store Name", Expect_Address = "Somewhere address";
[Link](Expect_StoreName, [Link]);
[Link](Expect_Address, [Link]);