コード例 #1
0
        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]));
        }
コード例 #2
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];
        }
コード例 #3
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);
 }
コード例 #4
0
        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]));

            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(() =>
                                                         recorder.GetRecordedExpectation(new FakeInvocation(voidNoArgs), demo,
                                                                                         voidNoArgs, new object[0]));
            Assert.Equal("IDemo.VoidNoArgs(); Expected #1, Actual #2.", ex.Message);
        }
コード例 #5
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.True(testRecorder.DoGetAllExpectationsForProxyCalled);
     Assert.Same(testRecorder, Get.Recorder(mocks));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalcExpectedAndActual"/> class.
 /// </summary>
 /// <param name="parent">
 /// The parent.
 /// </param>
 /// <param name="proxy">
 /// The proxy.
 /// </param>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <param name="args">
 /// The args.
 /// </param>
 public CalcExpectedAndActual(UnorderedMethodRecorder parent, object proxy, MethodInfo method, object[] args)
 {
     this.parent = parent;
     Calculate(proxy, method, args);
 }