public void RecordMethodsAndReplayThemInSameOrder()
        {
            OrderedMethodRecorder recorder = new OrderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            recorder.Record(this.demo, this.voidNoArgs, expectationOne);
            recorder.Record(this.demo, voidThreeArgs, new AnyArgsExpectation(new FakeInvocation(voidThreeArgs), new Range(1, 1)));

            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs), this.demo, this.voidNoArgs, new object[0]));
            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs), this.demo, this.voidThreeArgs, new object[0]));
        }
        public void RecordMethodsAndReplayThemOutOfOrder()
        {
            OrderedMethodRecorder recorder = new OrderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            recorder.Record(this.demo, this.voidNoArgs, expectationOne);
            recorder.Record(this.demo, this.voidThreeArgs, expectationOne);

            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(this.voidNoArgs), this.demo, this.voidNoArgs, new object[0]));
            string expectedMessage="Unordered method call! The expected call is: 'Ordered: { IDemo.VoidNoArgs(); }' but was: 'IDemo.VoidNoArgs();'";
            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
                () =>
                recorder.GetRecordedExpectation(new FakeInvocation(this.voidNoArgs), this.demo, this.voidNoArgs, new object[0]));
            Assert.Equal(expectedMessage, ex.Message);
        }
 public void ReplayWhenNoMethodIsExpected()
 {
     OrderedMethodRecorder recorder = new OrderedMethodRecorder(new ProxyMethodExpectationsDictionary());
     string expectedMessage="Unordered method call! The expected call is: 'Ordered: { No method call is expected }' but was: 'IDemo.VoidNoArgs();'";
     ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
         () =>
         recorder.GetRecordedExpectation(new FakeInvocation(this.voidNoArgs), this.demo, this.voidNoArgs, new object[0]));
     Assert.Equal(expectedMessage, ex.Message);
 }
 public void ReplayErrorWhenInOtherReplayer()
 {
     OrderedMethodRecorder recorder = new OrderedMethodRecorder(new ProxyMethodExpectationsDictionary());
     recorder.AddRecorder(new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary()));
     string expectedMessage="IDemo.VoidNoArgs(); Expected #0, Actual #1.";
     ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
         () =>
         recorder.GetRecordedExpectation(new FakeInvocation(this.voidNoArgs), this.demo, this.voidNoArgs, new object[0]));
     Assert.Equal(expectedMessage, ex.Message);
 }