0% found this document useful (0 votes)
3 views

TESTS Code

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

TESTS Code

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

INVENTORY

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

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();
inventory.AddProduct(product1);
Assert.AreEqual(1, inventory.Products.Count);
inventory.AddProduct(product2);
Assert.AreEqual(2, inventory.Products.Count);
inventory.AddProduct(product3);
Assert.AreEqual(3, inventory.Products.Count);
inventory.AddProduct(product4);
Assert.AreEqual(4, inventory.Products.Count);
// Product already in inventory. Add quantity
inventory.AddProduct(product5);
Assert.AreEqual(4, inventory.Products.Count);
Assert.AreEqual(16, product4.Quantity);

[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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);
IProduct expected = product3;
IProduct actual = inventory[24];
Assert.AreEqual(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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);
List<IProduct> expected = new List<IProduct>() { product1, product3 };
List<IProduct> actual = inventory["M Shirt"];
Assert.AreEqual(expected.Count, actual.Count);
Assert.AreEqual(0, actual.Except(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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);
Assert.AreEqual(11, inventory[25].Quantity);
// Product already in inventory. Subtract quantity
inventory.RemoveProduct(product5);
Assert.AreEqual(6, inventory[25].Quantity);
// Make sure the other products are not changed
Assert.AreEqual(78, inventory[22].Quantity);
Assert.AreEqual(12, inventory[23].Quantity);
Assert.AreEqual(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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
string expected = "Product is not in inventory.";
string actual = "";
// Product is not in inventory. Exception
try { inventory.RemoveProduct(product4); }
catch (Exception e) { actual = e.Message; }
Assert.AreEqual(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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product5);
string expected = "There is not enough quantity.";
string actual = "";
// Product is not in inventory. Exception
try { inventory.RemoveProduct(product4); }
catch (ArgumentOutOfRangeException e) { actual = e.Message; }
Assert.AreEqual(expected, actual.Substring(0, expected.Length));

[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;
Assert.AreEqual(1, inventory.Products.Count);
inventory += (product2);
Assert.AreEqual(2, inventory.Products.Count);
inventory += (product3);
Assert.AreEqual(3, inventory.Products.Count);
inventory += (product4);
Assert.AreEqual(4, inventory.Products.Count);
// Product already in inventory. Add quantity
inventory += (product5);
Assert.AreEqual(4, inventory.Products.Count);
Assert.AreEqual(16, product4.Quantity);

[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();
inventory.AddProduct(product1);
inventory.AddProduct(product2);
inventory.AddProduct(product3);
inventory.AddProduct(product4);
Assert.AreEqual(11, inventory[25].Quantity);
// Product already in inventory. Subtract quantity
inventory -= (product5);
Assert.AreEqual(6, inventory[25].Quantity);
// Make sure the other products are not changed
Assert.AreEqual(78, inventory[22].Quantity);
Assert.AreEqual(12, inventory[23].Quantity);
Assert.AreEqual(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");
product1.AddQuantity("S", 10, 15.0m);
product1.AddQuantity("M", 20, 20.0m);
product1.AddQuantity("L", 5, 10.0m);
ProductGarment product2 = new ProductGarment(22, "Shirt", "Men Shirt");
product2.AddQuantity("S", 2, 15.0m);
product2.AddQuantity("M", 3, 20.0m);
product2.AddQuantity("L", 5, 10.0m);
Inventory inventory = new Inventory();
inventory.AddProduct(product1);
Assert.AreEqual(10, ((ProductGarment)inventory[22]).SizePriceQuantity["S"].quantity);
// Product already in inventory. Subtract quantity
inventory.RemoveProduct(product2);
Assert.AreEqual(8, ((ProductGarment)inventory[22]).SizePriceQuantity["S"].quantity);
Assert.AreEqual(17, ((ProductGarment)inventory[22]).SizePriceQuantity["M"].quantity);
Assert.AreEqual(0, ((ProductGarment)inventory[22]).SizePriceQuantity["L"].quantity);

}
}
}

SALE
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

}
}
}

STORE
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