public void MockThrowsWhenReplacingBehaviorForNonMember() { // Set up. var mock = new MockStub(); Assert.That.Throws <NotSupportedException>( () => mock.SetBehavior(m => "?", () => "?"), ExpressionType.Constant, "identify a mockable member"); }
public void MockRunsReplacedBehaviorReturningData() { // Set up. var mock = new MockStub(); const string Question = "Well do ya?"; // Add custom behavior to see if it executes. mock.SetBehavior(m => m.GetMessage(), () => Question); Assert.AreEqual( Question, mock.GetMessage(), "Expected custom behavior to run."); }
public void MockRunsReplacedBehavior() { // Set up. var mock = new MockStub(); // Add custom behavior to see if it executes. var calls = 0; mock.SetBehavior(m => m.ShowMessage(), () => calls++); mock.ShowMessage(); Assert.AreEqual(1, calls, "Expected custom behavior to run."); }