This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES/Source/Modulos/Tienda web/Test/uOscCustomersController_test.pas
2007-06-11 15:29:06 +00:00

220 lines
6.0 KiB
ObjectPascal

unit uOscCustomersController_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, uCustomEditor,
uOscCustomersController, uOscAddressBookController,
uBizOscCustomers, uBizOscAddressBook;
type
// Test methods for class TClientesController
TestTOscCustomersController = class(TTestCase)
strict private
FOscCustomersController: IOscCustomersController;
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 TestNuevoConDireccionesYSalvar;
procedure RecuperarUnCliente;
end;
implementation
uses
schTiendaWebClient_Intf, uDADataTable,
SysUtils, Dialogs, uIDataModuleTiendaWeb,
uDataModuleTiendaWeb, uTiendaWebViewRegister, uHostMainForm;
constructor TestTOscCustomersController.Create(MethodName: string);
begin
inherited;
end;
destructor TestTOscCustomersController.Destroy;
begin
//uContactosViewRegister.UnRegisterViews;
inherited;
end;
procedure TestTOscCustomersController.RecuperarUnCliente;
var
ACustomer : IBizOscCustomer;
begin
ACustomer := FOscCustomersController.Buscar(400) as IBizOscCustomer;
CheckNotNull(ACustomer, 'Cliente ID=400 no encontrado');
// FOscCustomersController.Ver(ACustomer);
end;
procedure TestTOscCustomersController.SetUp;
begin
FOscCustomersController := TOscCustomersController.Create;
end;
procedure TestTOscCustomersController.TearDown;
begin
FOscCustomersController := nil;
end;
procedure TestTOscCustomersController.TestListar;
var
ACustomer : IBizOscCustomer;
begin
ACustomer := (FOscCustomersController.BuscarTodos as IBizOscCustomer);
// FOscCustomersController.VerTodos(ACustomer);
end;
procedure TestTOscCustomersController.TestVer;
begin
CheckTrue(False);
// TODO: Validate method results
end;
procedure TestTOscCustomersController.TestNuevo;
{var
ACustomer: IBizOscCustomer;}
begin
{ ACustomer := (FOscCustomersController.Nuevo as IBizOscCustomer);
Check(Assigned(ACustomer), 'Cliente no creado');
Check(ACustomer.ID < 0, 'Cliente creado pero con ID incorrecto');
CheckEquals('Cliente', ACustomer.Categoria, 'No es un cliente');
Check(Assigned(ACustomer.DatosBancarios), 'Al cliente le faltan los datos bancarios');
FOscCustomersController.Ver(ACustomer);}
end;
procedure TestTOscCustomersController.TestNuevoYSalvar;
var
ACustomer: IBizOscCustomer;
begin
ACustomer := (FOscCustomersController.Nuevo as IBizOscCustomer);
with ACustomer do
begin
Edit;
customers_firstname := 'First Name';
customers_lastname := 'Last Name';
customers_email_address := 'email@address.com';
customers_telephone := '9182828282';
customers_fax := '937373733';
customers_password := 'aaaa';
Post;
end;
FOscCustomersController.Guardar(ACustomer);
Check(ACustomer.customers_id >= 0, 'ID no asignado correctamente al contacto');
Check(False, 'ID asignado = ' + IntToStr(ACustomer.customers_id));
end;
procedure TestTOscCustomersController.TestNuevoConDireccionesYSalvar;
var
ACustomer: IBizOscCustomer;
I: Integer;
begin
ACustomer := (FOscCustomersController.Nuevo as IBizOscCustomer);
with ACustomer do
begin
Edit;
customers_firstname := 'First Name';
customers_lastname := 'Last Name';
customers_email_address := 'email@address.com';
customers_telephone := '9182828282';
customers_fax := '937373733';
customers_password := 'aaaa';
Post;
end;
with ACustomer.AddressBook do
begin
Check(Assigned(ACustomer.AddressBook), 'AddressBook no creado');
for i := 1 to 5 do
begin
Insert;
Check(address_book_id < 0, 'Datos bancarios nuevo pero con ID incorrecto');
entry_gender := 'M';
entry_company := 'Company ' + IntToStr(i);
entry_firstname := 'Firstname ' + IntToStr(i);
entry_lastname := 'Lastname ' + IntToStr(i);
entry_street_address := 'Street Address ' + IntToStr(i);
entry_suburb := 'Suburb ' + IntToStr(i);
entry_postcode := '1234 ' + IntToStr(i);
entry_city := 'City ' + IntToStr(i);
entry_state := 'State ' + IntToStr(i);
Post;
end;
end;
FOscCustomersController.Guardar(ACustomer);
Check(ACustomer.customers_id >= 0, 'ID no asignado correctamente al contacto');
Check((ACustomer.AddressBook.RecordCount = 5), 'Faltan filas de direcciones');
for i := 0 to ACustomer.AddressBook.RecordCount - 1 do
begin
ShowMessage('ID asignado = ' + IntToStr(ACustomer.AddressBook.address_book_id));
ACustomer.AddressBook.Next;
end;
ACustomer.Edit;
ACustomer.customers_default_address_id := ACustomer.AddressBook.address_book_id;
ACustomer.Post;
FOscCustomersController.Guardar(ACustomer);
end;
procedure TestTOscCustomersController.TestNuevoYVer;
{var
ACustomer: IBizOscCustomer;}
begin
{ CheckTrue(False);
ACustomer := (FOscCustomersController.Nuevo as IBizOscCustomer);}
end;
procedure TestTOscCustomersController.TestEncontrar;
var
ReturnValue: Boolean;
ID: Integer;
begin
CheckTrue(False);
// TODO: Setup method call parameters
// ReturnValue := FOscCustomersController.ExisteContacto(ID);
// TODO: Validate method results
end;
procedure TestTOscCustomersController.TestSalvar;
var
AContacto: IBizOscCustomer;
begin
CheckTrue(False);
// TODO: Setup method call parameters
// FOscCustomersController.Salvar(AContacto);
// TODO: Validate method results
end;
initialization
// Register any test cases with the test runner
RegisterTest(TestTOscCustomersController.Suite);
end.