public ItemServiceTests(ERPContextFactory catalogContextFactory, ITestOutputHelper testOutputHelper) { _itemRespository = new ItemRespository(catalogContextFactory.ContextInstance); _genreRespository = new GenreRespository(catalogContextFactory.ContextInstance); _artistRespository = new ArtistRespository(catalogContextFactory.ContextInstance); _itemMapper = catalogContextFactory.ItemMapper; _logger = new Mock <LoggerAbstraction <IItemService> >(); _logger .Setup(x => x.Log(It.IsAny <LogLevel>(), It.IsAny <Exception>(), It.IsAny <string>())) .Callback((LogLevel logLevel, Exception exception, string information) => testOutputHelper.WriteLine($"{logLevel}:{information}")); }
public async Task should_return_record_by_id(string guid) { DbContextOptions <ERPContext> options = new DbContextOptionsBuilder <ERPContext>() .UseInMemoryDatabase(databaseName: "should_return_record_by_id") .Options; await using TestERPContext context = new TestERPContext(options); context.Database.EnsureCreated(); ItemRespository sut = new ItemRespository(context); Item result = await sut.GetAsync(new Guid(guid)); result.Id.ShouldBe(new Guid(guid)); }
public ActionResult Shop(int?page, int sort_by, string sort_by_brand, string sort_by_prod) { var item = from x in _context.ItemMsts select x; if (!string.IsNullOrEmpty(sort_by_brand)) { item = item.Where(x => x.BrandMst.brandId.Contains(sort_by_brand)); } if (!string.IsNullOrEmpty(sort_by_prod)) { item = item.Where(x => x.ProductMst.prodId.Contains(sort_by_prod)); } ItemRespository ir = new ItemRespository(); ViewBag.BrandList = _context.BrandMsts.ToList(); ViewBag.ProdList = _context.ProductMsts.ToList(); ViewBag.ItemList = item.ToList().ToPagedList(page ?? 1, sort_by); return(View(item.ToList().ToPagedList(page ?? 1, sort_by))); }
//Shop page in default format for showing all products w customize filter public ActionResult Shop(string searchString, int?page, string sortBy, string sort_by_prod) { var item = from x in _context.ItemMsts select x; if (!string.IsNullOrEmpty(searchString)) { item = item.Where(x => x.itemName.Contains(searchString) || x.itemImg.Contains(searchString)); } if (!string.IsNullOrEmpty(sort_by_prod)) { item = item.Where(x => x.ProductMst.prodId.Contains(sort_by_prod)); } ItemRespository ir = new ItemRespository(); ViewBag.BrandList = _context.BrandMsts.ToList(); ViewBag.ProdList = _context.ProductMsts.ToList(); ViewBag.ItemList = item.Where(i => i.itemStatus == true).ToList().ToPagedList(page ?? 1, 6); return(View(item.Where(i => i.itemStatus == true).ToList().ToPagedList(page ?? 1, 6))); }
public ItemRespositoryTests(ERPContextFactory catlogContextFactory) { _context = catlogContextFactory.ContextInstance; _itemRespository = new ItemRespository(_context); }