public async Task VehicleService_DeleteAllTest() { IDatabaseRepo dbRepo = container.Resolve <IDatabaseRepo>(); List <Vehicle> vehiclesList = new List <Vehicle>() { new Vehicle() { Brand = "BMW", Model = "320D", Colour = "Black" }, new Vehicle() { Brand = "BMW", Model = "320D", Colour = "White" }, new Vehicle() { Brand = "AUDI", Model = "A5", Colour = "Black" } }; var result1 = await dbRepo.Create <Vehicle>(vehiclesList[0]); var result2 = await dbRepo.Create <Vehicle>(vehiclesList[1]); var result3 = await dbRepo.Create <Vehicle>(vehiclesList[2]); var result = await vehicleService.DeleteAll(); Assert.AreEqual(result, vehiclesList.Count); }
public async Task VehicleService_DeleteVehicleTest() { IDatabaseRepo dbRepo = container.Resolve <IDatabaseRepo>(); var vehicle = new Vehicle() { Brand = "BMW", Model = "320D", Colour = "Black" }; var result = await dbRepo.Create <Vehicle>(vehicle); var resultDelete = await vehicleService.DeleteVehicle(result.Id); Assert.IsTrue(resultDelete); }
public async Task VehicleService_UpdateVehicleTest() { IDatabaseRepo dbRepo = container.Resolve <IDatabaseRepo>(); var vehicle = new Vehicle() { Brand = "BMW", Model = "320D", Colour = "Black" }; //Save object o DB var result = await dbRepo.Create <Vehicle>(vehicle); //Edit Model object result.Model = "535I"; //Update the object on DB var resultUpdate = await vehicleService.UpdateVehicle(result.Id, result); Assert.AreEqual(resultUpdate.Model, result.Model); await vehicleService.DeleteVehicle(resultUpdate.Id); }
async Task <Vehicle> IVehicleService.AddVehicle(Vehicle v) { return(await dbRepo.Create <Vehicle>(v)); }