These are the release notes for Release 5.2.0.
|
||
New Features |
A new API dedicated
especially for Visual Basic.NET developers allows utilizing the
simplicity and elegance of the Arrange-Act-Assert principals in VB:
Dim fake As Logger = FakeInstance(Of Logger)()
' set behavior on the CanWrite() method Using TheseCalls.WillReturn(True) fake.CanWrite("c:\test.txt") End Using fake.Write("Hello World") ' assert that a call happened Using AssertCalls.HappenedWithExactArguments fake.WriteToDisk("c:\test.txt") End Using var fake =
Isolate.Fake.Instance<Logger>();
// use True Properties to set the behavior of the LogPath property // this is done regardless of the actual implementation of the property setter. fake.LogPath = "c:\test.txt" // the property getter now returns the set value Assert.AreEqual("c:\test.txt", fake.LogPath); var fake =
Isolate.Fake.Instance<LogFile>();
// use True Indexers to set the behavior of the index getter // the behavior will apply only to the index value in the WhenCalled() statement Isolate.WhenCalled(() => fake[0]).WillReturn("Hello"); Isolate.WhenCalled(() => fake[1]).WillReturn("World"); // when accessing the indexer it will return the set behavior depending on the index Assert.AreEqual("World", fake[1]); Assert.AreEqual("Hello", fake[0]); // when accessing the indexer at an index we did not set behavior for the default behavior is returned Assert.AreEqual("", fake[2]);
var fake =
Isolate.Fake.Instance<Logger>();
// use Behavior Sequencing to set up behavior on repeated calls to ReadFromLog() Isolate.WhenCalled(() => fake.ReadFromLog()).WillReturn("Hello"); Isolate.WhenCalled(() => fake.ReadFromLog()).WillReturn("World"); // the last sequenced value will be used as the default value once all values are returned Isolate.WhenCalled(() => fake.ReadFromLog()).WillReturn("DefaultValue"); // when the calls are made the return values are returned in the order they were sequenced at: Assert.AreEqual("Hello", fake.ReadFromLog()); Assert.AreEqual("World", fake.ReadFromLog()); Assert.AreEqual("DefaultValue", fake.ReadFromLog()); Assert.AreEqual("DefaultValue", fake.ReadFromLog()); |
|
|
||
General fixes |
In 5.2.1:
In 5.2.0:
|
|
|
||
Known Issues |
Isolate.WhenCalled(() =>
ProductFactory.GetProduct().Name).WillReturn("ProductA");
Isolate.WhenCalled(() => ProductFactory.GetProduct().Price).WillReturn(100); // may fail: the second behavior setting declaration overrid the first. Assert.AreEqual("ProductA", ProductFactory.GetProduct.Name); Isolate.WhenCalled(() => fake.Call(fake.Do())).WillReturn(0);
// not supported
// instead extract the inner chain to a variable: var innerChain = fake.Do(); Isolate.WhenCalled(() => fake.Call(innerChain)).WillReturn(0); // supported |
|
|
||