I have heard recently about Model Based Testing and searched for tools that can follow this approach.
As the result i found FsCheck.
At the Experimental page, the author describes how to create a model based test which can be executed.
That is all nice and everything, but sadly i do not understand what would be a difference between the actual object and the model of the object.
So, given the following code:
using System;
using System.Collections.Generic;
using System.Text;
namespace SimpleOrderApp
{
public class Order
{
private string _name;
private string _description;
private bool _isOnOrderList;
public Order(string name, string description)
{
_name = name;
_description = description;
_isOnOrderList = false;
}
public string Name {
get => _name;
set
{
if (!_isOnOrderList)
{
return;
}
_name = value;
}
}
public string Description
{
get => _description;
set
{
if (!_isOnOrderList)
{
return;
}
_description = value;
}
}
public bool IsOnOrderList
{
get => _isOnOrderList;
set => _isOnOrderList = value;
}
}
}
Spec: - User is able to provide an order name - User is able to provide an order description - User is not able to update the order if it is in the OrderList (IsOnOrderList = true)
Bug:
The code
if (!_isOnOrderList)
{
return;
}
Should not have !
.
Can somebody help me construct an OrderModel
, that i can use to validate my Order
object against and explain to me why it has to be done so? Currently, i am very keen to think that Order
and OrderModel
are identical.
UPD:
Would it be correct to state that the Model has same properties of the Object under test, but the values are simply hardcoded?