public void Initialize() { ArticleService = new ArticleServiceFake(); FieldService = new FieldServiceFake(); ProductService = new ProductServiceFake(); Logger = new LoggerFake(); TransactionFactory = () => new TransactionFake(); Action = new ActionBaseFake(ArticleService, FieldService, ProductService, TransactionFactory); Context = new ActionContext { ContentItemIds = new[] { ContentItemId } }; }
public async Task Detail_ReturnsNotFoundResult_WhenInvalidProductIdOrWebCompanyId() { // Arrange long productId = 1000; long webCompanyId = 1000; IProductService productServiceFake = new ProductServiceFake(); var mockRepo = new Mock <IProductService>(); mockRepo.Setup(repo => repo.Get(productId)) .Returns(productServiceFake.Get(productId)); ProductsController productsController = new ProductsController(mockRepo.Object); var result = await productsController.Details(productId); var viewResult = Assert.IsType <NotFoundResult>(result); }
public void Initialize() { ArticleService = new ArticleServiceFake(); NotificationService = new QPNotificationServiceFake(); FieldService = new FieldServiceFake(); FreezeService = new FreezeServiceFake(); ValidationService = new ValidationServiceFake(); ProductService = new ProductServiceFake { Content = new Content() { ContentId = ContentId } }; Transaction = null; Logger = new LoggerFake(); Context = new ActionContext(); InitializeAction(); }
public async Task Index_ReturnsAViewResult_WithAListOfProducts() { // Arrange long companyId = 1; IProductService productServiceFake = new ProductServiceFake(); var mockRepo = new Mock <IProductService>(); mockRepo.Setup(repo => repo.Get(companyId)) .Returns(productServiceFake.Get(companyId)); //mockRepo.VerifyAll(); ProductsController productsController = new ProductsController(mockRepo.Object); var result = await productsController.Index(); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <List <ProductDto> >(viewResult.ViewData.Model); Assert.Equal(3, model.Count); }