Пример #1
0
        public static IEnumerable <object[]> Get_ItemsByName_SampleData()
        {
            CategoryRQ categoryRQ = new CategoryRQ();

            categoryRQ.CategoryName = "Dress";
            List <CategoryRS> categoryRS = new List <CategoryRS>();

            CategoryRS categoryRS1 = new CategoryRS();

            categoryRS1.CategoryName    = "Dress";
            categoryRS1.SubCategoryName = "Sarees";
            categoryRS1.ItemName        = "Silk Sarees";
            categoryRS1.ItemDescription = "Hard and Softsilks are available";
            categoryRS.Add(categoryRS1);

            CategoryRS categoryRS2 = new CategoryRS();

            categoryRS2.CategoryName    = "Dress";
            categoryRS2.SubCategoryName = "Sarees";
            categoryRS2.ItemName        = "Cotton Sarees";
            categoryRS2.ItemDescription = "Pure and semi cotton sarees are available";
            categoryRS.Add(categoryRS2);

            CategoryRS categoryRS3 = new CategoryRS();

            categoryRS3.CategoryName    = "Dress";
            categoryRS3.SubCategoryName = "Tops";
            categoryRS3.ItemName        = "Leggin Tops";
            categoryRS3.ItemDescription = "All colors are available";
            categoryRS.Add(categoryRS3);

            CategoryRS categoryRS4 = new CategoryRS();

            categoryRS4.CategoryName    = "Dress";
            categoryRS4.SubCategoryName = "Tops";
            categoryRS4.ItemName        = "Jean Tops";
            categoryRS4.ItemDescription = "All colors are available";
            categoryRS.Add(categoryRS4);

            CategoryRS categoryRS5 = new CategoryRS();

            categoryRS5.CategoryName    = "Dress";
            categoryRS5.SubCategoryName = "Jeans";
            categoryRS5.ItemName        = "Ladies Jeans";
            categoryRS5.ItemDescription = "All Types are available";
            categoryRS.Add(categoryRS5);

            CategoryRS categoryRS6 = new CategoryRS();

            categoryRS6.CategoryName    = "Dress";
            categoryRS6.SubCategoryName = "Jeans";
            categoryRS6.ItemName        = "Boys Jeans";
            categoryRS6.ItemDescription = "All Types are available";
            categoryRS.Add(categoryRS6);


            yield return(new object[] { categoryRQ, categoryRS });
        }
Пример #2
0
        public void Test_ItemsByNameController(CategoryRQ categoryRQ, List <CategoryRS> ExpectedResult)
        {
            dynamic response   = new ExpandoObject();
            var     controller = new ShoppingController(_ShoppingModel);

            response = controller.Get_ItemsByName(categoryRQ);
            List <CategoryRS> actualResult = (List <CategoryRS>)response;

            Assert.Equal(ExpectedResult, actualResult);
        }
        public async Task <dynamic> Get_ItemsByName([FromBody] CategoryRQ categoryRQ)
        {
            dynamic response   = new ExpandoObject();
            int     nameLength = categoryRQ.CategoryName.Length;

            if (nameLength >= 3 && nameLength <= 12)
            {
                response = await _ShoppingModel.GetItemsDetailsByName(categoryRQ);
            }
            else
            {
                return("Invalid Input. Accepted string length is min = 3 and max = 12");
            }
            return(response);
        }