Defining RecordedCall in a TestProcessor

 Given a TestProcessor
 Should lookup RecordedCalls in a Log

Test Code using Static Constructs

    [TestClass]
    public class Given_TestProcessor : BehaviorOf<TestProcessor> {

        readonly TestProcessor Subject = Create.TestObjectFor<TestProcessor>();

        [TestMethod]
        public void Should_lookup_RecorderCalls_in_a_Log() {

            Assert.IsFalse(Subject.RecordedCall);
            Given.That(Subject).Log.Recorded(Subject.Call).WillReturn(true);
            Assert.IsTrue(Subject.RecordedCall);
        }
    }

Test Code using Extensions Constructs

    [TestClass]
    public class Given_TestProcessor : BehaviorOf<TestProcessor> {

        readonly TestProcessor Subject = Create.TestObjectFor<TestProcessor>();

        [TestMethod]
        public void Should_lookup_RecorderCalls_in_a_Log() {

            Assert.IsFalse(Subject.RecordedCall);
            Subject.Given().Log.Recorded(Subject.Call).WillReturn(true);
            Assert.IsTrue(Subject.RecordedCall);
        }
    }

Production Code

    public class TestProcessor {

        public Log Log { get; set; }
        public Call Call { get; set; }

        public bool RecordedCall {
            get { return Log.Recorded(Call); }
        }
    }

    public interface Log {

        bool Recorded(Call Call);
    }

    public interface Call {}

Last edited Nov 5, 2008 at 6:23 AM by mikemps, version 1

Comments

No comments yet.