EfetuarVendaTeste

From Grupo1 Ahand

Revision as of 00:52, 1 June 2007 by Denise cunha (Talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)

import junit.framework.TestCase;
import livraria.Cliente;
import livraria.CtrlEfetuarVenda;
import livraria.Livro;
import livraria.TEfetuarVenda;
import livraria.TMsgErro;


public class EfetuarVendaTeste extends TestCase {

public void testEfetuarVendaSemSucesso(){
String titulo = null;
String autor = null;
String userid = null;

TMsgErro tMsgErro = new TMsgErro();
CtrlEfetuarVenda ctrlEfetuarVenda = new CtrlEfetuarVenda();
TEfetuarVenda tEfetuarVenda = new TEfetuarVenda(ctrlEfetuarVenda);
ctrlEfetuarVenda.addPropertyChangeListener(tMsgErro);

Livro livro = new Livro(titulo ,autor);
tEfetuarVenda.InformarLivrosParaCompra(livro,1);
assertEquals("Livro invalido!", tMsgErro.getMsgErro());

Cliente cliente = new Cliente(userid);
tEfetuarVenda.InformarUserID(cliente);
assertEquals("User ID invalido!", tMsgErro.getMsgErro());
}

public void testEfetuarVendaComSucesso(){
String titulo = "A Rainha do Crime";
String autor = "Agatha Christie";
String userid = "Cliente1";

TMsgErro tMsgErro = new TMsgErro();
CtrlEfetuarVenda ctrlEfetuarVenda = new CtrlEfetuarVenda();
TEfetuarVenda tEfetuarVenda = new TEfetuarVenda(ctrlEfetuarVenda);
ctrlEfetuarVenda.addPropertyChangeListener(tMsgErro);

Livro livro = new Livro(titulo ,autor);
tEfetuarVenda.InformarLivrosParaCompra(livro,1);
assertNull(tMsgErro.getMsgErro());

Cliente cliente = new Cliente(userid);
tEfetuarVenda.InformarUserID(cliente);
assertNull(tMsgErro.getMsgErro());
}

}

Personal tools