public void CarRepository_UpdateTechnicalPassport_UpdatesTechnicalPassport() { var mockCarDbSet = UnitTestHelper.GetMockDbSet <Car>(GetTestCars()); var mockTechnicalPassportDbSet = UnitTestHelper.GetMockDbSet <TechnicalPassport>(GetTestTechnicalPassports()); var mockContext = GetMockContext(mockCarDbSet, mockTechnicalPassportDbSet); var carRepo = new CarRepository(mockContext.Object); var techPassport = new TechnicalPassport { CarId = 1, PrimaryDamage = "Damage" }; carRepo.UpdateTechnicalPassport(techPassport); mockTechnicalPassportDbSet.Verify( m => m.Attach(It.Is <TechnicalPassport>( p => p.CarId == techPassport.CarId && p.PrimaryDamage == techPassport.PrimaryDamage)), Times.Once); }
public void CarRepository_AddTechnicalPassport_AddsTechnicalPassport() { var mockCarDbSet = UnitTestHelper.GetMockDbSet <Car>(GetTestCars()); var mockTechnicalPassportDbSet = UnitTestHelper.GetMockDbSet <TechnicalPassport>(GetTestTechnicalPassports()); var mockContext = GetMockContext(mockCarDbSet, mockTechnicalPassportDbSet); var carRepo = new CarRepository(mockContext.Object); var technicalPassport = new TechnicalPassport { CarId = 100, PrimaryDamage = "Damage" }; carRepo.AddTechnicalPassport(technicalPassport); mockTechnicalPassportDbSet.Verify( m => m.Add(It.Is <TechnicalPassport>( c => c.CarId == technicalPassport.CarId && c.PrimaryDamage == technicalPassport.PrimaryDamage)), Times.Once); }
/// <summary> /// Adds technical passport to database /// </summary> /// <param name="technicalPassport"></param> public void AddTechnicalPassport(TechnicalPassport technicalPassport) { _context.TechnicalPassports.Add(technicalPassport); }
/// <summary> /// Updates technical passport /// </summary> /// <param name="technicalPassport"></param> public void UpdateTechnicalPassport(TechnicalPassport technicalPassport) { _context.TechnicalPassports.Attach(technicalPassport); }