Exemplo n.º 1
0
        public async Task OnGet_ReturnPaginatedList(decimal PriceFrom,
                                                    decimal PriceTo, string searchString)
        {
            //Arrange
            var mockProductsRep = new Mock <IProductsRepository>();

            mockProductsRep.Setup(_db => _db.GetAllProducts()).Returns(MockProducts.GetAllProductsTest()); //настрока: вызов нужного метода и передача данных
            var pageModel = new CatalogModel(mockProductsRep.Object, new Mock <IMaterialsRepository>().Object, new Mock <IManufacturersRepostory>().Object);

            //Act
            var result = await pageModel.OnGetAsync(PriceFrom, PriceTo, SortState.NameAsc, null, null, 1, searchString);

            //Assert
            Assert.IsType <PaginatedList <Products> >(result);
        }
Exemplo n.º 2
0
        public async Task OnGet_SearchReturnNotFound(string SearchString)
        {
            //Arrange
            var mockGalleryRep = new Mock <IGalleryRepository>();

            mockGalleryRep.Setup(_db => _db.SearchGallery(SearchString)).Returns(MockGallery.SearchGalleryTest(SearchString)); //настрока: вызов нужного метода и передача данных
            var mockProductsRep = new Mock <IProductsRepository>();

            mockProductsRep.Setup(_db => _db.SearchProduct(SearchString)).Returns(MockProducts.SearchProductsTest(SearchString)); //настрока: вызов нужного метода и передача данных
            var pageModel = new SearchModel(mockProductsRep.Object, mockGalleryRep.Object);

            //Act
            var result = await pageModel.OnGetAsync(SearchString);

            //Assert
            Assert.IsType <NotFoundResult>(result);
        }
 protected override void OnInitRecords() => Records.AddRange(MockProducts.GetProducts());