public async Task AddDrinkAsyncTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var newDrink = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1 }; var service = new DrinkRepository(context); await service.AddDrinkAsync(newDrink); } using (var context = new CoffeeDbContext(options)) { var newDrink = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1 }; var result = context.Drinks.Single(); //Assert.IsNull(result); Assert.AreEqual(1, context.Drinks.Count()); Assert.AreEqual(newDrink.DrinkName, result.DrinkName); } }
public OrderRepository( CoffeeDbContext context, IShoppingCartService shoppingCartService) { _context = context; _shoppingCartService = shoppingCartService; }
public async System.Threading.Tasks.Task CheckRequestTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var service = new TableRepository(context); TableRequest table = new TableRequest { Id = 1, FirstName = "FirstName", LastName = "LastName", Date = DateTime.Now.ToString(), Status = "Waiting", Note = "Test", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; await service.AddRequestAsync(table); } using (var context = new CoffeeDbContext(options)) { Assert.AreEqual(1, context.TableRequests.Count()); var service = new TableRepository(context); await service.CheckRequest(1, "Done"); Assert.AreEqual("Done", context.TableRequests.Single().Status); } }
public async Task GetDrinksTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var newDrink1 = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1, Category = new Category() }; var newDrink2 = new Drink { DrinkName = "test2", Description = "test2", Price = 200, CategoryId = 2, Category = new Category() }; var service = new DrinkRepository(context); await service.AddDrinkAsync(newDrink1); await service.AddDrinkAsync(newDrink2); } using (var context = new CoffeeDbContext(options)) { var service = new DrinkRepository(context); var result = service.GetDrinks(); Assert.AreEqual(2, result.Count()); } }
public AddProduct() { InitializeComponent(); _db = new CoffeeDbContext(); cboCategory.DataSource = _db.ProductsTypes.ToList(); cboCategory.DisplayMember = "Description"; cboCategory.ValueMember = "Id"; }
public async Task GetCategoryByIdAsyncTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var doanCategory = new Category { Id = 1, CategoryName = "Đồ ăn", Drinks = new List <Drink>() }; var thucuongCategory = new Category { Id = 2, CategoryName = "Thức uống", Drinks = new List <Drink>() }; var coffeeCategory = new Category { Id = 3, CategoryName = "Coffee", Drinks = new List <Drink>() }; var trangmiengCategory = new Category { Id = 4, CategoryName = "Tráng miệng", Drinks = new List <Drink>() }; context.Categories.Add(doanCategory); context.Categories.Add(thucuongCategory); context.Categories.Add(coffeeCategory); context.Categories.Add(trangmiengCategory); context.SaveChanges(); } using (var context = new CoffeeDbContext(options)) { var service = new CategoryRepository(context); var result = await service.GetCategoryByIdAsync(4); //Assert.AreEqual(4, context.Categories.Count()); Assert.AreEqual(4, result.Id); } }
public async System.Threading.Tasks.Task GetRequestsTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var service = new TableRepository(context); TableRequest table1 = new TableRequest { Id = 1, FirstName = "FirstName", LastName = "LastName", Date = DateTime.Now.ToString(), Status = "Waiting", Note = "Test", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; TableRequest table2 = new TableRequest { Id = 2, FirstName = "FirstName1", LastName = "LastName1", Date = DateTime.Now.ToString(), Status = "Waiting1", Note = "Test1", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; await service.AddRequestAsync(table1); await service.AddRequestAsync(table2); } using (var context = new CoffeeDbContext(options)) { Assert.AreEqual(2, context.TableRequests.Count()); var service = new TableRepository(context); var result = service.GetRequests(); Assert.AreEqual(2, result.Count()); } }
public ViewProducts() { InitializeComponent(); _db = new CoffeeDbContext(); dataGridView1.DataSource = _db.Products.ToList(); dataGridView1.Columns["ProductType"].Visible = false; dataGridView1.Columns["ProductTypeId"].Visible = false; cboFilter.DataSource = _db.ProductsTypes.ToList(); cboFilter.DisplayMember = "Description"; cboFilter.ValueMember = "Id"; }
public DictionaryRepository(CoffeeDbContext dbContext, IAppLogger <DictionaryRepository <T> > appLogger) { this._dbContext = dbContext; this._appLogger = appLogger; //GetRoles().Wait(); //GetAreas().Wait(); IEnumerable <Role> roles = _dbContext.Roles.ToList(); IEnumerable <Area> areas = _dbContext.Areas.ToList(); var tasks = new List <Task>() { GetRoles(roles), GetAreas(areas) }; WhenAllTasks(tasks); }
private void GenerateGraph() { using (var _db = new CoffeeDbContext()) { var query = from product in _db.TransactionItems group product by product.Product.Description into g select new { ProductId = g.Key, TotalUnitsSold = g.Count() }; chart1.DataSource = query; chart1.Series["Series1"].XValueMember = "ProductId"; chart1.Series["Series1"].YValueMembers = "TotalUnitsSold"; chart1.Series["Series1"].Name = "Products"; chart1.DataBind(); chart1.Show(); } }
public OwnerConfirmationRepository(CoffeeDbContext context) : base(context) { }
public HomeController(CoffeeDbContext coffeeDbContext, IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; }
public AreaRepository(CoffeeDbContext context) : base(context) { }
public TableRepository(CoffeeDbContext coffeeDbContext) { _coffeeDbContext = coffeeDbContext; }
public UnitOfWork(CoffeeDbContext coffeeDbContext) { _coffeeDbContext = coffeeDbContext; InitRepository(); }
public CategoryRepository(CoffeeDbContext coffeeDbContext) { _coffeeDbContext = coffeeDbContext; }
public Form1() { InitializeComponent(); _db = new CoffeeDbContext(); }
private ShoppingCartService(CoffeeDbContext context) { _context = context; }
public EfRepository(CoffeeDbContext dbContext) { _dbContext = dbContext; }
public RoasterTagRepository(CoffeeDbContext dbContext) => Context = dbContext ?? throw new ArgumentNullException(nameof(CoffeeDbContext));
public UserDao() { db = new CoffeeDbContext();//Khởi tạo db }
public StatisticController(CoffeeDbContext context) { _context = context; }
public PictureRequestRepository(CoffeeDbContext coffeeDbContext) => _coffeeDbContext = coffeeDbContext;
public HomeController(CoffeeDbContext db) { _db = db; }
public DrinkRepository(CoffeeDbContext coffeeDbContext) { _coffeeDbContext = coffeeDbContext; }
public TagRepository(CoffeeDbContext context) => Context = context ?? throw new ArgumentNullException(nameof(CoffeeDbContext));
public OwnerRepository(CoffeeDbContext context) : base(context) { }
public CoffeeService(CoffeeDbContext context) { this._context = context; }
private void DoLoading(object sender, DoWorkEventArgs e) { CoffeeDbContext dbContext = new CoffeeDbContext(); }
public RoasterRequestRepository(CoffeeDbContext context, ILogger logger) => _context = context ?? throw new ArgumentNullException(nameof(CoffeeDbContext));