public void Repository_Returns_Single_Product_When_Filtered_ByID_1() { ICatalogRepository rep = new TestCatalogRepository(); IList<Product> products = rep.GetProducts() .WithProductID(1) .ToList(); Assert.AreEqual(1, products.Count); }
public TestPersonalizationRepository() { eventList = new List<UserEvent>(); ICatalogRepository catalogRepository = new TestCatalogRepository(); //looking at products for (int i = 1; i < 50; i++) { for (int x = 10; x <= 20; x++) { Category c = catalogRepository .GetCategories().WithCategoryID(x).Take(1).SingleOrDefault(); //take the first Product p = c.Products[0]; UserEvent ue = new UserEvent("testuser", "127.0.0.1", c.ID, p.ID, System.Guid.Empty, UserBehavior.ViewProduct); eventList.Add(ue); //skew twice for 12 c = catalogRepository .GetCategories().WithCategoryID(12).Take(1).SingleOrDefault(); p = c.Products[0]; ue = new UserEvent("testuser", "127.0.0.1", c.ID, p.ID, System.Guid.Empty, UserBehavior.ViewProduct); eventList.Add(ue); } } //view some products for (int i = 1; i <= 5; i++) { Product p = catalogRepository.GetProducts().WithProductID(i).SingleOrDefault(); UserEvent ue = new UserEvent("testuser", "127.0.0.1", null, p.ID, System.Guid.Empty, UserBehavior.ViewProduct); eventList.Add(ue); } }
public TestInventoryRepository() { inventoryRecords = new List<InventoryRecord>(); //one for each product TestCatalogRepository catalog = new TestCatalogRepository(); List<Product> prods = catalog.GetProducts().ToList(); foreach (Product p in prods) { InventoryRecord rec = new InventoryRecord(p.ID,1,"test entry"); inventoryRecords.Add(rec); } }
public TestOrderRepository() { _order = _order ?? new Order("TESTORDER", "testuser"); _orders = new List<Order>(); _orders.Add(_order); //create the items _orderItems = new List<OrderItem>(); _addresses = new List<Address>(); for (int i = 0; i < 2; i++) { var add = new Address("testuser", "first" + i, "last" + i, "email" + i, "street1" + i, "street2" + i, "city" + i, "stateprovince" + i, "zip" + i, "country" + i); add.IsDefault = i == 1; add.ID = i; if (!_addresses.Contains(add)) _addresses.Add(add); } TestCatalogRepository catalog = new TestCatalogRepository(); for (int i = 0; i < 99; i++) { Order o = new Order("order" + i, "user" + 1); o.ID = Guid.NewGuid(); for (int x = 1; x <= 5; x++) { OrderItem item = new OrderItem(o.ID, catalog.GetProducts() .Where(y=>y.ID==x).SingleOrDefault()); item.Quantity = x == 5 ? 3 : 1; if(item.Quantity==1) item.Quantity = x == 4 ? 2 : 1; _orderItems.Add(item); o.Items.Add(item); } o.ShippingAddress = GetAddresses().Take(1).Skip(1).SingleOrDefault(); _orders.Add(o); } }
public void Product_Has_Three_Images() { ICatalogRepository rep = new TestCatalogRepository(); Product p = rep.GetProducts().Take(1).SingleOrDefault() ; Assert.AreEqual(3, p.Images.Count); }
public void CatalogRepository_Contains_Products() { ICatalogRepository rep = new TestCatalogRepository(); Assert.IsNotNull(rep.GetProducts()); }
public void Product_Has_A_DeliveryMethod_Setting() { ICatalogRepository rep = new TestCatalogRepository(); Product p = rep.GetProducts().Take(1).SingleOrDefault(); Assert.AreEqual(p.Delivery, DeliveryMethod.Shipped); }