public void WhenGettingOtherUsersVehicle_ThenThrowsInvalidOperationException()
        {
            int userId = this.defaultTestUser.UserId;
            var repository = new VehicleRepository(new MileageStatsDbContext());

            var vehicle = new Vehicle {Name = "Vehicle"};

            repository.Create(userId, vehicle);

            var repositoryForVerify = new VehicleRepository(new MileageStatsDbContext());
            Assert.Throws<InvalidOperationException>(() => repositoryForVerify.GetVehicle(42, vehicle.VehicleId));
        }
        public void WhenVehicleModifiedInSameContext_ThenPersistsChange()
        {
            IUnitOfWork uow = new MileageStatsDbContext();
            int userId = this.defaultTestUser.UserId;
            var repository = new VehicleRepository(uow);

            Vehicle vehicle = new Vehicle {Name = "Vehicle", UserId = userId};
            repository.Create(userId, vehicle);

            // I use a new context and repository to verify the data was stored
            var repositoryForUpdate = new VehicleRepository(uow);

            var retrievedVehicle = repositoryForUpdate.GetVehicles(userId).First();

            retrievedVehicle.Name = "Updated Vehicle Name";
            repositoryForUpdate.Update(retrievedVehicle);
            int updatedVehicleId = retrievedVehicle.VehicleId;

            var repositoryForVerify = new VehicleRepository(uow);
            var updatedVehicle = repositoryForVerify.GetVehicle(userId, updatedVehicleId);

            Assert.Equal("Updated Vehicle Name", updatedVehicle.Name);
        }