2-services model
Interestingly enough, when modeling more than one service, the model will also generate tests that verify services continue functioning even when others go down. Essentially what we are checking here is that we don’t have any unnecessary dependencies between the services, and that a service won’t hang because another one is down.
When designing models including more than one service the state-space can rapidly explode. Consider adding just another service: Payment Service into the model which we depend on upon check-out.
We extend our model by adding:
public class PaymentService : ModelService
{
public override string Name { get { return "Payment"; } }
public void ProcessPayment()
{
ConditionRunning();
}
}
And changing the model to:
static class WebshopModelProgram
{
static ShoppingCartService cartService = new ShoppingCartService();
static PaymentService paymentService = new PaymentService();
[Rule(Action = "AddToCart()")]
static void AddToCart()
{
cartService.AddItem();
}
[Rule(Action = "ProceedToCheckOut()/result")]
static bool ProceedToCheckOut()
{
if(cartService.Count() == 0)
return false;
cartService.Empty();
paymentService.ProcessPayment();
return true;
}