public void TestFindById() { using (RaceContext context = new RaceContext()) { using (CarCRUD CarCRUD = new CarCRUD(new RaceContext())) { var car = new Cars { Name = "Test2", DriverName = "Test2" }; context.Cars.Add(car); context.SaveChanges(); Assert.Equal(car.Id, CarCRUD.FindById(car.Id).Id); } } }
public void FindById_given_id_returns_car() { var cc = new CarCRUD(context); var car = new Car { Name = "Car Two", DriverName = "Driver Two" }; cc.Create(car); var expected = car; var actual = cc.FindById(car.CarId); Assert.Equal(expected.CarId, actual.CarId); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.DriverName, actual.DriverName); context.Remove(car); context.SaveChanges(); }