public JsonResult GetList() { ProductStub productService = new ProductStub(); var productList = productService.GetProductList(); return(new JsonResult(productList)); }
public MockProductRepository DeleteProductAsync() { Setup(x => x.DeleteAsync(It.Is <Guid>(e => e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) || e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns(() => Task.FromResult(ProductStub.DeleteProduct())); Setup(x => x.DeleteAsync(It.Is <Guid>(e => !e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) && !e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns(() => Task.FromResult(ProductStub.NoDeleteProduct())); return(this); }
public MockProductService ExistProductAsync() { Setup(x => x.ExistProductAsync(It.Is <Guid>(e => e.Equals(Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3")) || e.Equals(Guid.Parse("A16C605C-0A1A-4E63-857F-68019CE2575C"))))) .Returns((Guid id) => Task.FromResult(ProductStub.ExistProduct())); Setup(x => x.ExistProductAsync(It.Is <Guid>(e => !e.Equals(Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3")) && !e.Equals(Guid.Parse("A16C605C-0A1A-4E63-857F-68019CE2575C"))))) .Returns(() => throw new BusinessException("Product doesn't exist")); return(this); }
public MockProductRepository ExistProductAsync() { Setup(x => x.ExistsAsync(It.Is <Guid>(e => e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) || e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a")) || e.Equals(Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3"))))) .Returns((Guid id) => Task.FromResult(ProductStub.ExistProduct())); Setup(x => x.ExistsAsync(It.Is <Guid>(e => !e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) && !e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns(() => Task.FromResult(ProductStub.NotExistProduct())); return(this); }
public MockProductService ExistProductAsync() { Setup(x => x.ExistProductAsync(It.Is <Guid>(e => e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) || e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a")) || e.Equals(Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3"))))) .Returns((Guid id) => Task.FromResult(ProductStub.ExistProduct())); Setup(x => x.ExistProductAsync(It.Is <Guid>(e => !e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) && !e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns(() => throw new BusinessException("Product doesn't exist")); return(this); }
public MockProductService GetProductByIdAsync() { Setup(x => x.GetProductByIdAsync(It.Is <Guid>(e => e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) || e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns((Guid id) => Task.FromResult(ProductStub.GetProductById(id))); Setup(x => x.GetProductByIdAsync(It.Is <Guid>(e => !e.Equals(Guid.Parse("4d8830e2-465c-4a54-ad02-f875073c85dc")) && !e.Equals(Guid.Parse("7a56023f-4811-4a75-9768-6aaf7985bb1a"))))) .Returns(() => Task.FromResult <Product>(ProductStub.NoReturnProductById())); return(this); }
private static void AddProduct(ProductStub stub) { Driver.ClickId("create-new-product-link"); Driver.FindElementById("ProductName").SendKeys(stub.Name); Driver.FindElementById("Slug").SendKeys(stub.Slug); Driver.FindElementById("Description").SendKeys(stub.Description); Driver.SelectDropdownText("CategoryId", stub.Category); var imageFilePath = Path.Combine(Directory.GetCurrentDirectory(), "Assets", stub.Image + ".jpg"); Driver.FindElementById("product-image-file-chooser").SendKeys(imageFilePath); Driver.ClickId("submit-new-product-button"); foreach (var color in stub.Colors) { Driver.FindElementByName("newColor").SendKeys(color); Driver.ClickId("submit-add-color-button"); } foreach (var size in stub.Sizes) { Driver.FindElementByName("size").SendKeys(size); Driver.ClickId("add-size-submit-button"); foreach (var color in stub.Colors) { Driver.SelectDropdownText("ColorId", color); Driver.SelectDropdownText("SizeId", size); Driver.FindElementByName("Price").SendKeys(stub.Price.ToString(CultureInfo.InvariantCulture)); Driver.ClickId("add-style-submit-button"); } } Driver.FindElementById("additional-image-chooser").SendKeys(imageFilePath); Driver.ClickId("upload-additional-image-button"); }
public MockProductRepository InsertProductAsync() { Setup(x => x.InsertAsync(It.IsAny <Product>())) .Returns((Product product) => Task.FromResult(ProductStub.InsertProduct(product))); return(this); }
public MockProductRepository Queryable() { Setup(x => x.Queryable()).Returns(() => ProductStub.GetAllProductQueryable()); return(this); }
public MockProductRepository GetNotProductAsync() { Setup(x => x.GetAllAsync()).Returns(() => Task.FromResult <IEnumerable <Product> >(ProductStub.GetNotProductAsync())); return(this); }
public MockProductRepository GetAllProductAsync() { Setup(x => x.GetAllAsync()).Returns(() => Task.FromResult(ProductStub.GetAllProducts())); return(this); }
public MockProductService InsertProductAsync() { Setup(x => x.InsertProductAsync(It.IsAny <CreateProduct>())) .Returns((Product product) => Task.FromResult(ProductStub.InsertProduct(product))); return(this); }
public MockProductService GetNotProductAsync() { Setup(x => x.GetProductsAsync()).Returns(() => Task.FromResult <IEnumerable <Product> >(ProductStub.GetNotProductAsync())); return(this); }
public MockProductService GetAllProductAsync() { Setup(x => x.GetProductsAsync()).Returns(() => Task.FromResult(ProductStub.GetAllProducts())); return(this); }