public void Setup() { AutoMapper.Mapper.Initialize(mapper => { mapper.CreateMap <CartItems, CartItemsDto>().ReverseMap(); mapper.CreateMap <Categories, CategoriesDto>().ReverseMap(); mapper.CreateMap <OrderDetails, OrderDetailsDto>().ReverseMap(); mapper.CreateMap <Orders, OrdersDto>().ReverseMap(); mapper.CreateMap <Products, ProductsDto>().ReverseMap(); }); _wingtiptoysContext = new WingtiptoysContext(); _categoryServices = new CategoryServices(_wingtiptoysContext); _productsServices = new ProductsServices(_wingtiptoysContext); }
public ProductRepositoryTests() { _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); var options = new DbContextOptionsBuilder <WingtiptoysContext>() .UseSqlite(_connection) .Options; _context = new WingtiptoysContext(options); _context.Database.EnsureCreated(); _context.Categories.Add(new Category() { CategoryId = 1, CategoryName = "N1", Description = "D" }); _context.Categories.Add(new Category() { CategoryId = 2, CategoryName = "N2", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 1, ProductName = "ProductName1", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 1, ProductName = "ProductName2", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 1, ProductName = "ProductName3", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 1, ProductName = "ProductName4", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 1, ProductName = "ProductName5", Description = "D" }); _context.Products.Add(new Product() { CategoryId = 2, ProductName = "ProductName6", Description = "D" }); _context.SaveChanges(); }
public ProductsServices(WingtiptoysContext wingtiptoysContext) { _wingtiptoysContext = wingtiptoysContext; }
public OrderDetailsServices(WingtiptoysContext wingtiptoysContext) { _wingtiptoysContext = wingtiptoysContext; }
public CategoryServices(WingtiptoysContext wingtiptoysContext) { _wingtiptoysContext = wingtiptoysContext; }
public CartItemsServices(WingtiptoysContext wingtiptoysContext) { _wingtiptoysContext = wingtiptoysContext; }