0% found this document useful (0 votes)
26 views17 pages

Day 4 - Person

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views17 pages

Day 4 - Person

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

using System;

using System.Collections.Generic;
using System.Text;

namespace ICT711_Day4_classes
{
public class Person : IPerson
{
public string FName { get ; set ; }
public string LName { get ; set ; }
public string Tel { get ; set ; }
public string Email { get ; set ; }

public string GetFullName()


{
// throw new NotImplementedException();
return FName + " " + LName;
}
}
}

namespace ICT711_Day4_classes
{
public interface IPerson
{
public string FName { get; set; }
public string LName { get; set; }
public string Tel { get; set; }
public string Email { get; set; }
public string GetFullName();

}
}

--

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace ICT711_Day5_classes
{
public class Sale : ISale

{
public int Id { get; set; }
public DateTime Date { get; set; }
public int CustomerId { get; set; }
public int AssociateId { get; set; }

public Sale()
{
this.Id = new Random().Next();
}

public Sale(int customerId, int associateId, SaleStatus status)


{
this.Id = new Random().Next();
this.CustomerId = customerId;
this.AssociateId = associateId;
this.Status = status;
}

public Sale(int id, DateTime date, int customerId, int associateId, SaleStatus status)
{
this.Id = id;
this.Date = date;
this.CustomerId = customerId;
this.AssociateId = associateId;
this.Status = status;
}

private List<Product> productsList;

public List<Product> ProductsList


{
get
{
if (productsList == null) productsList = new List<Product>();
return productsList;
}
}

public SaleStatus Status { get; set; }

public int AddProduct(Product product, IInventory inventory)


{
Product inventoryProduct = (Product)inventory[product.ProductId];
if (inventoryProduct == null) throw new Exception("Invalid product");
if (inventoryProduct.Quantity < product.Quantity) throw new Exception("Insufficient quantity");

foreach (var p in ProductsList)


{
if (p.ProductId == product.ProductId)
{

inventory.RemoveProduct(product);
p.Add(product);

return 1;
};
}

inventory.RemoveProduct(product);
ProductsList.Add(product);

return 1;
}
public decimal GetTotal()
{
decimal total = 0;

foreach (Product product in ProductsList)


{
total += product.Price * product.Quantity;
}

return total;
}

public int RemoveProduct(Product product, IInventory inventory)


{

foreach (Product saleProduct in ProductsList)


{
if (saleProduct.ProductId == product.ProductId)
{
if (saleProduct.Quantity < product.Quantity) throw new Exception("Insufficient quantity");

saleProduct.Remove(product);
inventory.AddProduct(product);
return 1;
}
}

throw new Exception("Invalid product");


}

}
}

--
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ICT711_Day5_classes;
using System;
using System.Collections.Generic;
using System.Text;

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();
Assert.IsInstanceOfType(sale.Id, typeof(int));
Assert.IsTrue(sale.Id >= 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, SaleStatus.Returned);
// Check Id
Assert.IsInstanceOfType(sale.Id, typeof(int));
Assert.IsTrue(sale.Id >= 0);
Assert.AreEqual(4, sale.CustomerId); // CustomerId
Assert.AreEqual(1, sale.AssociateId); // AssociateId
Assert.AreEqual(SaleStatus.Returned, sale.Status); // 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, SaleStatus.Returned);
// Check Sale Id
Assert.IsInstanceOfType(sale.Id, typeof(int));
Assert.IsTrue(sale.Id == 550);
Assert.AreEqual(0, new DateTime(2020, 10, 1).CompareTo(sale.Date)); // Date
Assert.AreEqual(4, sale.CustomerId); // CustomerId
Assert.AreEqual(1, sale.AssociateId); // AssociateId
Assert.AreEqual(SaleStatus.Returned, sale.Status); // 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, SaleStatus.Returned);


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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);

sale.AddProduct(new Product((Product)inventory[22]) { Quantity = 3 }, inventory);


sale.AddProduct(new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
Assert.AreEqual(2, sale.ProductsList.Count);
Assert.AreEqual(23, sale.ProductsList[1].ProductId);
Assert.AreEqual(75, inventory[22].Quantity); // Make sure the sold quantity is deducted from inventory
Assert.AreEqual(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, SaleStatus.Returned);


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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);

sale.AddProduct(new Product((Product)inventory[22]) { Quantity = 3 }, inventory);


sale.AddProduct(new Product((Product)inventory[23]) { Quantity = 2 }, inventory);
decimal expected = product1.Price * 3 + product2.Price * 2;
decimal actual = sale.GetTotal();
Assert.AreEqual(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, SaleStatus.Returned);


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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);

sale.AddProduct(new Product((Product)inventory[22]) { Quantity = 3 }, inventory);


sale.AddProduct(new Product((Product)inventory[23]) { Quantity = 2 }, inventory);

sale.RemoveProduct(new Product((Product)inventory[23]) { Quantity = 1 }, inventory);


Assert.AreEqual(2, sale.ProductsList.Count);
Assert.AreEqual(23, sale.ProductsList[1].ProductId);
Assert.AreEqual(1, sale.ProductsList[1].Quantity);
Assert.AreEqual(75, inventory[22].Quantity); // Make sure the sold quantity is deducted from inventory
Assert.AreEqual(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, SaleStatus.Returned);
ProductGarment product3 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
product3.AddQuantity("S", 10, 15.0m);
ProductGarment product4 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
product4.AddQuantity("S", 30, 15.0m);
product4.AddQuantity("L", 30, 41.0m);
Inventory inventory = new Inventory();
inventory.AddProduct(product4);

sale.AddProduct(product3, inventory);
Assert.AreEqual(1, sale.ProductsList.Count);
Assert.AreEqual(24, sale.ProductsList[0].ProductId);
Assert.AreEqual(10, ((ProductGarment)sale.ProductsList[0]).SizePriceQuantity["S"].quantity);

sale.AddProduct(product3, inventory);
Assert.AreEqual(1, sale.ProductsList.Count);
Assert.AreEqual(20, ((ProductGarment)sale.ProductsList[0]).SizePriceQuantity["S"].quantity);

ProductGarment product5 = new ProductGarment(24, "M Shirt S", "Men Shirt Small");
product5.AddQuantity("S", 5, 15.0m);
sale.RemoveProduct(product5, inventory);
Assert.AreEqual(15, ((ProductGarment)sale.ProductsList[0]).SizePriceQuantity["S"].quantity);

Assert.AreEqual(15, ((ProductGarment)inventory[24]).SizePriceQuantity["S"].quantity); // Make sure the


updated sold quantity is deducted from inventory

}
}
}

--

using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Newtonsoft.Json;
//using Newtonsoft.Json.Serialization;

namespace ICT711_Day5_classes
{
public class Store : IStore
{
public string StoreName { get; set; }
public string Address { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<ICustomer> Customers { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<IAssociate> Associates { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public Inventory Inventory { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<ISale> Sales { get; set; }
[JsonProperty]
public static string AssociatesFileName { get; set; } = "associates.json";
[JsonProperty]
public static string CustomersFileName { get; set; } = "customers.json";
[JsonProperty]
public static string InventoryFileName { get; set; } = "inventory.json";
[JsonProperty]
public static string SalesFileName { get; set; } = "sales.json";
public static string StoreFileName { get; set; } = "store.json";

public Store()
{
this.StoreName = "New Store Name";
this.Address = "Somewhere address";
}
public void LoadAssociates()
{
string jsonString = File.ReadAllText(AssociatesFileName);
var ss = JsonConvert.DeserializeObject<List<Associate>>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
Associates = ss.ConvertAll(s => (IAssociate)s); // Typecasting for each element
//throw new NotImplementedException();
}

public void LoadCustomers()


{
string jsonString = File.ReadAllText(CustomersFileName);
var ss = JsonConvert.DeserializeObject<List<Customer>>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
Customers = ss.ConvertAll(s => (ICustomer)s);
// Typecasting for each element
//throw new NotImplementedException();
}

public void LoadInventory()


{
string jsonString = File.ReadAllText(InventoryFileName);
Inventory = JsonConvert.DeserializeObject<Inventory>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});

// Typecasting for each element


//throw new NotImplementedException();
}

public void LoadSales()


{
string jsonString = File.ReadAllText(SalesFileName);
var ss = JsonConvert.DeserializeObject<List<ISale>>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
Sales = ss.ConvertAll(s => (ISale)s);
return;
// Typecasting for each element
//throw new NotImplementedException();
}

public void SaveAssociates()


{
string jsonString = JsonConvert.SerializeObject(Associates, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
File.WriteAllText(AssociatesFileName, jsonString);
return;
//throw new NotImplementedException();
}

public void SaveCustomers()


{
string jsonString = JsonConvert.SerializeObject(Customers, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
File.WriteAllText(CustomersFileName, jsonString);
return;
}

public void SaveInventory()


{
string jsonString = JsonConvert.SerializeObject(Inventory, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
File.WriteAllText(InventoryFileName, jsonString);
return;
}

public void SaveSales()


{
string jsonString = JsonConvert.SerializeObject(Sales, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
File.WriteAllText(SalesFileName, jsonString);
return;
}

public void SaveStoreInfo(string StoreDataFileName = null)


{
Dictionary<string, string> StoreDetails = new Dictionary<string, string>();
StoreDetails[StoreName] = Address;

string jsonString = JsonConvert.SerializeObject(StoreDetails, Formatting.Indented, new JsonSerializerSettings


{
TypeNameHandling = TypeNameHandling.Auto
});
File.WriteAllText("store.json", jsonString);

public static Store CreateStore() // Factory method


{
if (!File.Exists(StoreFileName)) // in case no file exists
{
return new Store();
}
string jsonString = File.ReadAllText(StoreFileName);
return JsonConvert.DeserializeObject<Store>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});

}
}
}

--

using Microsoft.VisualStudio.TestTools.UnitTesting;

using ICT711_Day5_classes;

using System;

using System.Collections.Generic;

using System.Text;

using System.IO;

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.

//Assert.Fail();

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 } };

store.SaveAssociates();

int expected = 1155;

int actual = File.ReadAllBytes(Store.AssociatesFileName).Length;

Assert.IsTrue(Math.Abs(expected - actual) < 10);

[TestMethod()]

public void SaveCustomersTest()

// After creating your class, Remove the next line and uncomment the below test code.

//Assert.Fail();

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 } };

store.SaveCustomers();
int expected = 1125; // 1072

int actual = File.ReadAllBytes(Store.CustomersFileName).Length;

Assert.IsTrue(Math.Abs(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");

product4.AddQuantity("S", 10, 15.0m);

product4.AddQuantity("M", 20, 20.0m);

product5.AddQuantity("S", 5, 15.0m);

product5.AddQuantity("M", 7, 19.0m);

product5.AddQuantity("S", 10, 15.0m);

Inventory inventory = new Inventory();

inventory.AddProduct(product1);

inventory.AddProduct(product2);

inventory.AddProduct(product3);

inventory.AddProduct(product4);

inventory.AddProduct(product5);
ISale sale1 = new Sale(550, new DateTime(2020, 10, 1), 4, 1, SaleStatus.Returned);

sale1.AddProduct(new Product((Product)inventory[22]) { Quantity = 3 }, inventory);

sale1.AddProduct(new Product((Product)inventory[23]) { Quantity = 2 }, inventory);

sale1.AddProduct(new Product((Product)inventory[24]) { Quantity = 4 }, inventory);

ISale sale2 = new Sale(555, new DateTime(2020, 10, 10), 4, 1, SaleStatus.Complete);

sale2.AddProduct(new Product((Product)inventory[22]) { Quantity = 1 }, inventory);

sale2.AddProduct(new Product((Product)inventory[23]) { Quantity = 2 }, inventory);

ProductGarment prod1 = (ProductGarment)((ProductGarment)inventory[25]).Clone();

prod1.SizePriceQuantity.Clear();

prod1.AddQuantity("S", 2, 15.0m);

prod1.AddQuantity("M", 1, 20.0m);

sale2.AddProduct(prod1, inventory);

ProductGarment prod2 = (ProductGarment)((ProductGarment)inventory[26]).Clone();

prod2.SizePriceQuantity.Clear();

prod2.AddQuantity("S", 3, 15.0m);

prod2.AddQuantity("M", 4, 19.0m);

sale2.AddProduct(prod2, inventory);

IStore store = new Store() { Sales = new List<ISale>() { sale1, sale2 } };

store.SaveSales();

int expected = 2217;

int actual = File.ReadAllBytes(Store.SalesFileName).Length;

Assert.IsTrue(Math.Abs(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");

product4.AddQuantity("S", 10, 15.0m);

product4.AddQuantity("M", 20, 20.0m);

product5.AddQuantity("S", 5, 15.0m);

product5.AddQuantity("M", 7, 19.0m);

product5.AddQuantity("S", 10, 15.0m);

Inventory inventory = new Inventory();

inventory.AddProduct(product1);

inventory.AddProduct(product2);

inventory.AddProduct(product3);

inventory.AddProduct(product4);

inventory.AddProduct(product5);

IStore store = new Store() { Inventory = inventory };

store.SaveInventory();

int expected = 1358;

int actual = File.ReadAllBytes(Store.InventoryFileName).Length;

Assert.IsTrue(Math.Abs(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();

inventory.AddProduct(product1);

IStore store = new Store() { Inventory = inventory, StoreName = "New Store Name", Address =
"Somewhere address" };

store.Associates = new List<IAssociate>() { new Associate() { AssociateId = 2 } };

store.Customers = new List<ICustomer>() { new Customer(100, "John", "Smith", "40300000",


"[email protected]") };

store.SaveStoreInfo();

string stringContents = File.ReadAllText(Store.StoreFileName);

Assert.IsTrue(stringContents.Contains("New Store Name"));

Assert.IsTrue(stringContents.Contains("Somewhere address"));

Assert.IsTrue(!stringContents.Contains("CustomerId")); // Should not include customer


information

Assert.IsTrue(!stringContents.Contains("Products")); // Should not include inventory information

Assert.IsTrue(!stringContents.Contains("AssociateId")); // Should not include Associates


information

Assert.IsTrue(!stringContents.Contains("ProductsList")); // Should not include Sales information

Assert.IsTrue(stringContents.Length < 500);


}

[TestMethod()]

public void LoadAssociatesTest()

// After creating your class, Remove the next line and uncomment the below test code.

//Assert.Fail();

IStore store = new Store();

store.LoadAssociates();

Assert.AreEqual(4, store.Associates.Count);

Assert.AreEqual(1, store.Associates[0].AssociateId);

Assert.AreEqual(78, store.Associates[1].AssociateId);

Assert.AreEqual("Sam", store.Associates[2].FName);

Assert.AreEqual("40388888", store.Associates[3].Tel);

Assert.AreEqual("Marketing", store.Associates[3].Department);

Assert.AreEqual(1, store.Associates[2].ManagerId);

[TestMethod()]

public void LoadCustomersTest()

// After creating your class, Remove the next line and uncomment the below test code.

//Assert.Fail();

IStore store = new Store();

store.LoadCustomers();

Assert.AreEqual(4, store.Customers.Count);
Assert.AreEqual(100, store.Customers[0].CustomerId);

Assert.AreEqual(110, store.Customers[1].CustomerId);

Assert.AreEqual("Eddy", store.Customers[2].FName);

Assert.AreEqual("40399999", store.Customers[3].Tel);

[TestMethod()]

public void LoadSalesTest()

// After creating your class, Remove the next line and uncomment the below test code.

//Assert.Fail();

IStore store = new Store();

store.LoadSales();

Assert.AreEqual(2, store.Sales.Count);

Assert.AreEqual(4, store.Sales[0].CustomerId);

Assert.AreEqual(1, store.Sales[0].AssociateId);

Assert.AreEqual(3, store.Sales[0].ProductsList.Count);

Assert.AreEqual(4, store.Sales[1].ProductsList.Count);

Assert.AreEqual("Men Shirt", store.Sales[1].ProductsList[0].Description);

Assert.AreEqual(17.47m, store.Sales[1].ProductsList[1].Price);

Assert.IsInstanceOfType(store.Sales[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();

store.LoadInventory();

Assert.AreEqual(5, store.Inventory.Products.Count);

Assert.AreEqual("Men Shirt", store.Inventory[22].Description);

Assert.AreEqual("Ladies Shirt", store.Inventory[25].ProductName);

Assert.AreEqual(17.47m, store.Inventory[23].Price);

Assert.AreEqual(10, store.Inventory[24].Quantity);

Assert.IsInstanceOfType(store.Inventory[25], typeof(ProductGarment));

Assert.IsInstanceOfType(store.Inventory[26], typeof(ProductGarment));

Assert.AreEqual(2, ((ProductGarment)store.Inventory[26]).SizePriceQuantity.Count);

Assert.AreEqual(358.0m, ((ProductGarment)store.Inventory[26]).GetSubTotal());

[TestMethod()]

public void CreateStoreTest()

Store store = Store.CreateStore();

string Expect_StoreName = "New Store Name", Expect_Address = "Somewhere address";

Assert.AreEqual(Expect_StoreName, store.StoreName);

Assert.AreEqual(Expect_Address, store.Address);

You might also like