예제 #1
0
 public void ChangeRecorderOnCtor()
 {
     IMethodRecorder recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
     MethodRecorderBaseTests.TestMethodRecorder testRecorder = new MethodRecorderBaseTests.TestMethodRecorder();
     new RecorderChanger(mocks, recorder, testRecorder);
     recorder.GetAllExpectationsForProxy(new object());
     Assert.IsTrue(testRecorder.DoGetAllExpectationsForProxyCalled);
     Assert.AreSame(testRecorder, Get.Recorder(mocks));
 }
        public void CanRecordMethodsAndVerifyThem()
        {
            UnorderedMethodRecorder recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            recorder.Record(demo, voidNoArgs, new AnyArgsExpectation(new FakeInvocation(voidNoArgs), new Range(1, 1)));
            recorder.Record(demo, voidThreeArgs, new AnyArgsExpectation(new FakeInvocation(voidNoArgs), new Range(1, 1)));

            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidThreeArgs),demo, voidThreeArgs, new object[0]));
            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs),demo, voidNoArgs, new object[0]));
        }
예제 #3
0
        public ComplexOrderingTests()
        {
            recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            nestedRecorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            recorder.AddRecorder(nestedRecorder);

            proxy = new object();
            method = typeof (object).GetMethod("ToString");
            expectation = new AnyArgsExpectation(new FakeInvocation(method), new Range(1, 1));
            args = new object[0];
        }
예제 #4
0
 public void ChangeBackOnDispose()
 {
     IMethodRecorder recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
     MethodRecorderBaseTests.TestMethodRecorder testRecorder = new MethodRecorderBaseTests.TestMethodRecorder();
     using (new RecorderChanger(mocks, recorder, testRecorder))
     {
         Assert.Same(testRecorder, Get.Recorder(mocks));
     }
     Assert.NotSame(testRecorder, Get.Recorder(mocks));
     testRecorder.DoRecordCalled = false;
     recorder.Record(proxy, method, expectation);
     Assert.False(testRecorder.DoRecordCalled);
 }
        public void ReplayUnrecordedMethods()
        {
            UnorderedMethodRecorder recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
            recorder.Record(demo, voidNoArgs, new AnyArgsExpectation(new FakeInvocation(voidNoArgs), new Range(1, 1)));
            recorder.Record(demo, voidThreeArgs, new AnyArgsExpectation(new FakeInvocation(voidNoArgs), new Range(1, 1)));

            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidThreeArgs),demo, voidThreeArgs, new object[0]));
            Assert.NotNull(recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs),demo, voidNoArgs, new object[0]));

            Assert.Throws<ExpectationViolationException>("IDemo.VoidNoArgs(); Expected #1, Actual #2.",
                                                         () =>
                                                         recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs), demo,
                                                                                         voidNoArgs, new object[0]));
        }
예제 #6
0
 public CalcExpectedAndActual(UnorderedMethodRecorder parent, object proxy, MethodInfo method, object[] args)
 {
     this.parent = parent;
     Calculate(proxy, method, args);
 }
예제 #7
0
 public void ChangeRecorderTwice()
 {
     IMethodRecorder recorder = new UnorderedMethodRecorder(new ProxyMethodExpectationsDictionary());
     MethodRecorderBaseTests.TestMethodRecorder testRecorder = new MethodRecorderBaseTests.TestMethodRecorder();
     using (new RecorderChanger(mocks, recorder, testRecorder))
     {
         Assert.AreSame(testRecorder, Get.Recorder(mocks));
         MethodRecorderBaseTests.TestMethodRecorder testRecorder2 = new MethodRecorderBaseTests.TestMethodRecorder();
         using (new RecorderChanger(mocks, recorder, testRecorder2))
         {
             Assert.AreSame(testRecorder2, Get.Recorder(mocks));
             testRecorder2.DoRecordCalled = false;
             recorder.Record(proxy, method, expectation);
             Assert.IsTrue(testRecorder2.DoRecordCalled);
         }
         Assert.AreSame(testRecorder, Get.Recorder(mocks));
         testRecorder.DoRecordCalled = false;
         recorder.Record(proxy, method, expectation);
         Assert.IsTrue(testRecorder.DoRecordCalled);
     }
     Assert.AreNotSame(testRecorder, Get.Recorder(mocks));
     testRecorder.DoRecordCalled = false;
     recorder.Record(proxy, method, expectation);
     Assert.IsFalse(testRecorder.DoRecordCalled);
 }
 public CalcExpectedAndActual(UnorderedMethodRecorder parent, object proxy, MethodInfo method, object[] args)
 {
     this.parent = parent;
     Calculate(proxy, method, args);
 }