public void AddEngine() { var mockSet = new Mock <DbSet <Engine> >(); var mockContext = new Mock <CarDealershipContext>(); mockContext.Setup(m => m.Engines).Returns(mockSet.Object); var service = new EngineBusiness(mockContext.Object); service.Add(new Engine()); mockSet.Verify(m => m.Add(It.IsAny <Engine>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
//cbGet and cbSort// //Buttons + attached// private void btnAdd_Click(object sender, EventArgs e) { Engine engine = new Engine(); engine.Name = txtName.Text; engine.FuelType = FuelBGTtoENG(txtFuelType.Text); decimal.TryParse(txtEconomy.Text, out decimal economy); engine.EconomyPerHundredKm = economy; int.TryParse(txtDisplacement.Text, out int displacement); engine.Displacement = displacement; int.TryParse(txtPower.Text, out int power); engine.Power = power; EngineBusiness engineBusiness = new EngineBusiness(); engineBusiness.Add(engine); PopulateDataGridViewDefault(); ClearTextBoxes(); }