public async Task ExecuteAsync() { var Truck = await FindTruck(findTruckQuery); PrintTruck(Truck); Write("Deseja excluir o Caminhão? (S/N): "); var input = ReadKey(); if (input.Key == ConsoleKey.S) { WriteLine(); var command = new DeleteTruck(Truck.Chassis); var result = await deleteTruck.ExecuteAsync(command); if (result.IsSuccess) { WriteLine("O Caminhão foi excluido com sucesso!"); } else { WriteLine($"Não foi possível excluir o Caminhão: {result.Message}"); } } }
public async Task Command_Execute_ShouldDelete() { var context = GetInMemorySeededContext(); var delete = new DeleteTruckCommand(context); var command = new DeleteTruck("TEST1"); await delete.ExecuteAsync(command); var exists = context.Truck.Any(v => v.Chassis == "TEST1"); Assert.IsFalse(exists); }