Beispiel #1
0
        public void Cannot_Get_Data_When_Not_Contain_KeyString()
        {
            MyMock myMock = new MyMock();
            string key    = "GPU";

            myMock.ProductRepository.Setup(m => m.Products).Returns(GetProductsData());
            var controller = new WebApiController(myMock.ProductRepository.Object);

            ProductsListJsonViewModel result = controller.GetSpecifyProductIntro("ALL", key);

            Assert.AreEqual(0, result.Products.Count());
        }
Beispiel #2
0
        public void Can_Get_Data_With_KeyString()
        {
            MyMock myMock = new MyMock();
            string key    = "2";

            myMock.ProductRepository.Setup(m => m.Products).Returns(GetProductsData());
            var controller = new WebApiController(myMock.ProductRepository.Object);

            ProductsListJsonViewModel result = controller.GetSpecifyProductIntro("ALL", key);

            Assert.AreEqual(3, result.Products.Count());
            Assert.AreEqual(1, result.TotalPage);
            Assert.AreEqual("smartphone2", result.Products.First().Name);
        }
Beispiel #3
0
        public void Can_Get_Data()
        {
            MyMock myMock = new MyMock();

            myMock.ProductRepository.Setup(m => m.Products).Returns(GetProductsData());
            var controller = new WebApiController(myMock.ProductRepository.Object);

            ProductsListJsonViewModel result = controller.GetSpecifyProductIntro("ALL");

            Assert.AreEqual(5, result.CategoryList.Count());
            Assert.AreEqual("ALL", result.CategoryList.First());
            Assert.AreEqual(10, result.Products.Count());
            Assert.AreEqual(2, result.TotalPage);
        }