/// <summary> /// This will consolidate the products in a single list for /// lawnmover, phonecase and tshirt /// </summary> /// <param name="Currency"></param> /// <returns></returns> public List <Product> GetAll(Currency?Currency) { double newChangePrice = 1; ps = new List <Product>(); if (Currency.HasValue) { switch (Currency.Value) { case Models.Currency.Dollars: newChangePrice = 0.76; break; case Models.Currency.Euros: newChangePrice = 0.67; break; default: break; } } GetProducts(_lawnmowerRepository.GetAll(), ProductType.Lawnmover, newChangePrice); GetProducts(_phoneCaseRepository.GetAll(), ProductType.PhoneCase, newChangePrice); GetProducts(_tShirtRepository.GetAll(), ProductType.TShirt, newChangePrice); // Default sorting by name return(ps.OrderBy(x => x.Type).ToList()); }
public void TestRate() { var consolidator = new ProductDataConsolidator(); var l = new LawnmowerRepository(); var p = new PhoneCaseRepository(); var t = new TShirtRepository(); var lawnmowers = l.GetAll(); var phoneCases = p.GetAll(); var tshirts = t.GetAll(); consolidator.Consolidate(lawnmowers); consolidator.Consolidate(phoneCases); consolidator.Consolidate(tshirts); var products = consolidator.GetAll(); var rate = 0.67; consolidator.Rate = 0.67; var i = 0; foreach (var lawnmower in lawnmowers) { AssertEqual(products[i++], lawnmower, rate); } foreach (var phoneCase in phoneCases) { AssertEqual(products[i++], phoneCase, rate); } foreach (var tshirt in tshirts) { AssertEqual(products[i++], tshirt, rate); } }