Exemple #1
0
        public void DataContextGetAllTest()
        {
            MyProductContext myProductContext = new MyProductContext();

            myProductContext.Add(getMyProducts());
            Assert.AreEqual(myProductContext.GetAll().Count, 504);
        }
Exemple #2
0
        public void GetTotalStandardCostByCategoryTest()
        {
            MyProductContext myProductContext = new MyProductContext();

            myProductContext.Add(getMyProducts());
            MyProductService myProductService = new MyProductService(myProductContext);
            ProductCategory  categoryName     = DataService.getCategoryFromString("Components");
            decimal          cost             = myProductService.GetTotalStandardCostByCategory(categoryName);

            Assert.AreEqual(35930.3944m, cost);
        }
Exemple #3
0
        public void GetProductsByNameTest()
        {
            MyProductContext myProductContext = new MyProductContext();

            myProductContext.Add(getMyProducts());
            MyProductService myProductService = new MyProductService(myProductContext);
            List <MyProduct> p1 = myProductService.GetProductsByName("Blade");
            List <MyProduct> p2 = myProductService.GetProductsByName("Flat Washer");
            List <MyProduct> p3 = myProductService.GetProductsByName("2137");

            Assert.AreEqual(1, p1.Count);
            Assert.AreEqual(9, p2.Count);
            Assert.AreEqual(0, p3.Count);
        }
Exemple #4
0
        public void GetNMyProductFromCategoryTest()
        {
            MyProductContext myProductContext = new MyProductContext();

            myProductContext.Add(getMyProducts());
            MyProductService myProductService = new MyProductService(myProductContext);
            List <MyProduct> list             = myProductService.GetNMyProductFromCategory("Components", 4);

            Assert.AreEqual(list.Count, 4);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(list[i].ProductSubcategory.ProductCategory.Name, "Components");
            }
        }