I am trying to incorporate BDD into the teams working practices to make interactions with Business Analysts more effective. I recently asked this question: Should I pass an ID number from the feature file?
Please see the code below:
public class Chestnut
{
private Guid _id;
public Customer (Guid id)
{
if (id == Guid.Empty)
throw new ArgumentException();
_id = id;
}
//Chestnut methods go here.
}
How would I test this class if I was using Specflow (like in my other question)? I was thinking about creating two tests:
1) A Chestnut is created because a valid ID is passed. 2) A Chestnut is not created because an empty ID is passed.
I was thinking about doing the following:
1) Given an ID; Then create a Chestnut with a valid state
2) Given an empty ID Then a validation error is presented for ID
Note that I am not specifying the ID in the actual scenario - because it is an implementation detail.
Is this a "good" test or is there another way of approaching this? Should I even be creating a test for this?