Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        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();
        }