Information Technology Reference
In-Depth Information
testprogram PlaceOrder{
nc := new NewCustomer
(name:='John', eMailAddress:='john@john.com', password:='pwd');
assert occurrence nc;
john := nc.createdCustomer;
ns := new NewSession;
assert occurrence ns;
s := ns.createdSession;
np1 := new NewProduct(name:='shirt', netPrice:=20, quantityOnHand:=5);
assert occurrence np1;
shirt := np1.createdProduct;
np2 := new NewSpecial (name:='trousers', netPrice:=80,
quantityOnHand:=25,specialNetPrice:=65);
assert occurrence np2;
trousers := np2.createdProduct;
test confirmOrder{
apsc1 := new AddProductToShoppingCart(quantity:=2,
session:=s, product:=shirt);
assert occurrence apsc1;
apsc2 := new AddProductToShoppingCart(quantity:=1,
session:=s, product:=trousers);
assert occurrence apsc2;
assert equals s.shoppingCart.shoppingCartItem->at(1).price 40;
assert equals s.shoppingCart.shoppingCartItem->at(2).price 65;
li := new LogIn(customer:=john, session:=s);
assert occurrence li;
oc := new OrderConfirmation(shoppingCart:= s.customer.shoppingCart);
assert occurrence oc;
assert equals oc.createdOrder.total 105;
assert equals shirt.quantityOrdered 2;
assert equals oc.createdOrder.eMail 'john@john.com';
assert equals oc.createdOrder.name 'John';
assert equals oc.createdOrder.orderLine->at(1).name 'shirt';
assert equals oc.createdOrder.orderLine->at(2).name 'trousers';
}
test productKindsInCatalog{
ndp := new NewDownloadableProduct
(name:='fashionDesigner', netPrice:=43, quantityOnHand:=85,
link:='http://fashionshop.com/fashionDesigner.zip');
assert occurrence ndp;
nds := new NewDownloadableSpecial
(name:='FashionTipsMagazine', netPrice:=3, quantityOnHand:=15,
specialNetPrice := 2,
link:='http://fashionshop.com/tips.pdf');
assert occurrence nds;
}
}
Fig. 3 CSTL program for testing order placement
The statement creates the instance eventId of EventType 1 , and assigns a value
to its characteristics (attributes att 1 , ..., att n and binary links with roles r 1 ,..., r m ). In
Fig. 3 there are ten examples of statements that create an instance of a domain event
type.
Once the concrete event eventId has been created in a test case, in order to assert
that it may occur in the current state of the IB the conceptual modeler writes the
following sentence:
assert occurrence eventId;
The verdict of this assertion is determined as follows:
Check that the current IB state is consistent. The verdict is Error if that check
fails (events may not occur in inconsistent IB states). In general, a state of the
 
Search WWH ::




Custom Search