public MockOrderItemRepository() { var _mockBookRepository = new MockBookRepository(); _orderItemList = new List <OrderItem> { new OrderItem { Id = 1, Book = _mockBookRepository.GetById(1), Quantity = 1 }, new OrderItem { Id = 2, Book = _mockBookRepository.GetById(2), Quantity = 5 }, new OrderItem { Id = 3, Book = _mockBookRepository.GetById(3), Quantity = 2 } }; }
public void SetUp() { dbContext = new DbContextOptionsBuilder <AppDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); var bookRepo = new MockBookRepository(); book1 = bookRepo.Books.FirstOrDefault(i => i.Id == 1); book2 = bookRepo.Books.FirstOrDefault(i => i.Id == 2); _context = new AppDbContext(dbContext.Options); sc = new ShoppingCart(_context); shoppingCartItem1 = new ShoppingCartItem() { Book = book1, Quantity = 1, ShoppingCartId = sc.ShoppingCartId }; shoppingCartItem2 = new ShoppingCartItem() { Book = book2, Quantity = 3, ShoppingCartId = sc.ShoppingCartId }; }
public BookItemsController(BookContext context) { _context = context; _mockBookRepository = new MockBookRepository(); }