198 lines
5.2 KiB
ObjectPascal
198 lines
5.2 KiB
ObjectPascal
|
|
unit uClientesController_test;
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Delphi DUnit Test Case
|
|||
|
|
----------------------
|
|||
|
|
This unit contains a skeleton test case class generated by the Test Case Wizard.
|
|||
|
|
Modify the generated code to correctly setup and call the methods from the unit
|
|||
|
|
being tested.
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
TestFramework, uIEditorCliente,
|
|||
|
|
uIEditorClientes, uClientesController, uCustomEditor, uBizContactos;
|
|||
|
|
type
|
|||
|
|
// Test methods for class TClientesController
|
|||
|
|
|
|||
|
|
TestTClientesController = class(TTestCase)
|
|||
|
|
strict private
|
|||
|
|
FClientesController: IClientesController;
|
|||
|
|
public
|
|||
|
|
procedure SetUp; override;
|
|||
|
|
procedure TearDown; override;
|
|||
|
|
constructor Create(MethodName: string); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
published
|
|||
|
|
procedure TestListar;
|
|||
|
|
procedure TestVer;
|
|||
|
|
procedure TestNuevo;
|
|||
|
|
procedure TestNuevoYVer;
|
|||
|
|
procedure TestEncontrar;
|
|||
|
|
procedure TestSalvar;
|
|||
|
|
procedure TestNuevoYSalvar;
|
|||
|
|
procedure RecuperarUnCliente;
|
|||
|
|
procedure SeleccionarUnCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
schContactosClient_Intf, uDADataTable,
|
|||
|
|
SysUtils, Dialogs, uIDataModuleContactos, uDataModuleContactos,
|
|||
|
|
uBizDatosBancarios,
|
|||
|
|
uContactosViewRegister, uHostMainForm;
|
|||
|
|
|
|||
|
|
constructor TestTClientesController.Create(MethodName: string);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TestTClientesController.Destroy;
|
|||
|
|
begin
|
|||
|
|
//uContactosViewRegister.UnRegisterViews;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.RecuperarUnCliente;
|
|||
|
|
var
|
|||
|
|
ACliente : IBizCliente;
|
|||
|
|
begin
|
|||
|
|
ACliente := FClientesController.Buscar(400) as IBizCliente;
|
|||
|
|
CheckNotNull(ACliente, 'Cliente ID=400 no encontrado');
|
|||
|
|
FClientesController.Ver(ACliente);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.SeleccionarUnCliente;
|
|||
|
|
var
|
|||
|
|
AClientes : IBizCliente;
|
|||
|
|
ACliente : IBizCliente;
|
|||
|
|
begin
|
|||
|
|
AClientes := (FClientesController.BuscarTodos as IBizCliente);
|
|||
|
|
CheckNotNull(AClientes, 'Clientes no encontrados');
|
|||
|
|
ACliente := (FClientesController.ElegirContacto(AClientes, 'Selecciona una lciente', False) as IBizCliente);
|
|||
|
|
CheckNotNull(ACliente, 'Cliente no elegido');
|
|||
|
|
FClientesController.Ver(ACliente);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.SetUp;
|
|||
|
|
begin
|
|||
|
|
FClientesController := TClientesController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TearDown;
|
|||
|
|
begin
|
|||
|
|
FClientesController := nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestListar;
|
|||
|
|
var
|
|||
|
|
AContactos : IBizCliente;
|
|||
|
|
begin
|
|||
|
|
AContactos := (FClientesController.BuscarTodos as IBizCliente);
|
|||
|
|
FClientesController.VerTodos(AContactos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestVer;
|
|||
|
|
begin
|
|||
|
|
CheckTrue(False);
|
|||
|
|
// TODO: Validate method results
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestNuevo;
|
|||
|
|
var
|
|||
|
|
ACliente: IBizCliente;
|
|||
|
|
begin
|
|||
|
|
ACliente := (FClientesController.Nuevo as IBizCliente);
|
|||
|
|
Check(Assigned(ACliente), 'Cliente no creado');
|
|||
|
|
Check(ACliente.ID < 0, 'Cliente creado pero con ID incorrecto');
|
|||
|
|
CheckEquals('Cliente', ACliente.Categoria, 'No es un cliente');
|
|||
|
|
Check(Assigned(ACliente.DatosBancarios), 'Al cliente le faltan los datos bancarios');
|
|||
|
|
FClientesController.Ver(ACliente);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestNuevoYSalvar;
|
|||
|
|
var
|
|||
|
|
ACliente: IBizCliente;
|
|||
|
|
I: Integer;
|
|||
|
|
begin
|
|||
|
|
ACliente := (FClientesController.Nuevo as IBizCliente);
|
|||
|
|
with ACliente do
|
|||
|
|
begin
|
|||
|
|
NIF_CIF := '1234567890-X';
|
|||
|
|
NOMBRE := 'David Arranz Puerta';
|
|||
|
|
CALLE := 'Dehesa de Vic<69>lvaro, 47 2<>C';
|
|||
|
|
POBLACION := 'Madrid';
|
|||
|
|
PROVINCIA := 'Madrid';
|
|||
|
|
CODIGO_POSTAL := '28053';
|
|||
|
|
TELEFONO_1 := '123456789';
|
|||
|
|
TELEFONO_2 := '9876543231';
|
|||
|
|
MOVIL_1 := '101918171615141312';
|
|||
|
|
MOVIL_2 := '010203040506070809';
|
|||
|
|
FAX := '1111111111';
|
|||
|
|
EMAIL_1 := 'porqueyolovalgo@osea.com';
|
|||
|
|
EMAIL_2 := 'fromlost@totheriver.com';
|
|||
|
|
PAGINA_WEB := 'http://www.trapicheos.com';
|
|||
|
|
DataTable.Post;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with ACliente.DatosBancarios do
|
|||
|
|
begin
|
|||
|
|
Check(Assigned(ACliente.DatosBancarios), 'Datos bancarios no creado');
|
|||
|
|
for i := 1 to 5 do
|
|||
|
|
begin
|
|||
|
|
Insert;
|
|||
|
|
Check(ID < 0, 'Datos bancarios nuevo pero con ID incorrecto');
|
|||
|
|
TITULAR := ACliente.NOMBRE;
|
|||
|
|
ENTIDAD := '1931';
|
|||
|
|
SUCURSAL := '3034';
|
|||
|
|
DC := '15';
|
|||
|
|
CUENTA := '000000' + IntToStr(i);
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
FClientesController.Guardar(ACliente);
|
|||
|
|
|
|||
|
|
Check(ACliente.ID >= 0, 'ID no asignado correctamente al contacto');
|
|||
|
|
Check((ACliente.DatosBancarios.RecordCount = 5), 'Faltan filas de datos bancarios');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestNuevoYVer;
|
|||
|
|
var
|
|||
|
|
ACliente: IBizCliente;
|
|||
|
|
begin
|
|||
|
|
CheckTrue(False);
|
|||
|
|
ACliente := (FClientesController.Nuevo as IBizCliente);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestEncontrar;
|
|||
|
|
var
|
|||
|
|
ReturnValue: Boolean;
|
|||
|
|
ID: Integer;
|
|||
|
|
begin
|
|||
|
|
CheckTrue(False);
|
|||
|
|
// TODO: Setup method call parameters
|
|||
|
|
// ReturnValue := FClientesController.ExisteContacto(ID);
|
|||
|
|
// TODO: Validate method results
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TestTClientesController.TestSalvar;
|
|||
|
|
var
|
|||
|
|
AContacto: IBizCliente;
|
|||
|
|
begin
|
|||
|
|
CheckTrue(False);
|
|||
|
|
// TODO: Setup method call parameters
|
|||
|
|
// FClientesController.Salvar(AContacto);
|
|||
|
|
// TODO: Validate method results
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
// Register any test cases with the test runner
|
|||
|
|
RegisterTest(TestTClientesController.Suite);
|
|||
|
|
end.
|
|||
|
|
|