I use an older version of Typemock, and I am slightly confused. While I write tests, I don't do them everyday to be fluent in them.
My questions are thus:
The older way of doing thigs is using methods which record the expectations, such as:
using (RecordExpectations recorder = new RecordExpectations())
{
var dataLayer = new DataLayer();
recorder.ExpectAndReturn(dataLayer.GetCustomer(0), customer);
}
The pattern is, we record our expectations and then run the method (is this a mock object?) to see if we get the right result as expected.
However, now the pattern is:
var v = Get<Type> etc etc. Real example from
https://www.typemock.com/Mocking_and_Iso ... esting.php :
[Test]
[Isolated]
public void GetCustomerPriceGroup_Adult()
{
var dataLayer = Isolate.Fake.Instance<Datalayer>(Members.ReturnRecursiveFakes);
Isolate.SwapNextInstance<Datalayer>().With(dataLayer);
var carInsurance = new CarInsurance();
PriceGroup priceGroup = carInsurance.GetCustomerPriceGroup(0);
Assert.AreEqual(PriceGroup.Adult, priceGroup, "Incorrect price group");
}
I assume this is the same thing as recording expectations?
Basically, the syntax is .NET 3.5 I am assuming this is just because the product has moved on? Is there any reason not to use the recorder (wrapped in a using block)?
Also, Isolator checks the validity of arguments. This is exactly what NUnit does. It seems like I could ditch NUnit?
I'm ok with unit testing, but mock testing and writing good business logic to make the tests easier to write is a skill I need practise in. Any tips/urls/books which can help with this will be appreciated. :)
Thanks