using MockingFrameworksCompare.BrainSample;
using NUnit.Framework;
using MockingFrameworksCompare.BrainSample.Stubs;
namespace StubsTests
{
///
/// Brain test implementation using Stubs.
/// Stubs home page: http://research.microsoft.com/stubs
///
[TestFixture]
public class BrainTests
{
///
/// Verify that if hand throws an exception having touched a hot iron, gets called.
///
///
/// Stubs can mock both interfaces and classes - however, only virtual methods
/// of a class can be mocked (try changing IHand/IMouth to Hand/Mouth).
///
[Test]
public void TouchHotIron_Yell()
{
var hand = new SIHand();
var mouth = new SIMouth();
hand.TouchIron = (iron) =>
{
if (iron.IsHot)
throw new BurnException();
};
bool yelled = false;
mouth.Yell = () => yelled = true;
var brain = new Brain(hand, mouth);
brain.TouchIron(new Iron { IsHot = true });
Assert.IsTrue(yelled);
}
}
}