public void OnAfterCallIntercepted(ICompletedFakeObjectCall call, IFakeObjectCallRule ruleThatWasApplied)
 {
     if (call.Method.Name.Equals("TrapConstraints"))
     {
         call.GetArgument <Action>(0).Invoke();
     }
 }
            public void RecordCall(ICompletedFakeObjectCall call)
            {
                var attribute = new XAttribute("type", call.ReturnValue.GetType().AssemblyQualifiedName);
                var element   = new XElement("call", attribute, Serialize(call.ReturnValue));

                this.Xml.Root.Add(element);
            }
 public static int RecordSequenceNumber(ICompletedFakeObjectCall call)
 {
     int sequenceNumber = GetNextSequenceNumber();
     var box = SequenceNumbers.GetOrCreateValue(call);
     box.Value = sequenceNumber;
     return sequenceNumber;
 }
        /// <summary>
        /// Records the specified call.
        /// </summary>
        /// <param name="fakeObjectCall">The call to record.</param>
        public virtual void RecordCall(ICompletedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");

            var callData = new CallData(fakeObjectCall.Method, GetOutputArgumentsForCall(fakeObjectCall), fakeObjectCall.ReturnValue);
            this.recordedCalls.Add(new CallDataMetadata { HasBeenApplied = true, RecordedCall = callData });
        }
        /// <summary>
        /// Records the specified call.
        /// </summary>
        /// <param name="call">The call to record.</param>
        public virtual void RecordCall(ICompletedFakeObjectCall call)
        {
            var callData = new CallData(call.Method, GetOutputArgumentsForCall(call), call.ReturnValue);

            this.recordedCalls.Add(new CallDataMetadata {
                HasBeenApplied = true, RecordedCall = callData
            });
        }
        public static int RecordSequenceNumber(ICompletedFakeObjectCall call)
        {
            int sequenceNumber = GetNextSequenceNumber();
            var box            = SequenceNumbers.GetOrCreateValue(call);

            box.Value = sequenceNumber;
            return(sequenceNumber);
        }
            public void OnAfterCallIntercepted(ICompletedFakeObjectCall call, IFakeObjectCallRule ruleThatWasApplied)
            {
                Guard.AgainstNull(call, nameof(call));

                if (call.Method.Name.Equals("TrapConstraints"))
                {
                    this.realTrap.TrapConstraints(call.GetArgument <Action>(0));
                }
            }
            public void OnAfterCallIntercepted(ICompletedFakeObjectCall call)
            {
                Guard.AgainstNull(call, nameof(call));

                if (call.Method.Name == "TrapConstraints")
                {
                    this.realTrap.TrapConstraints(call.GetArgument <Action>(0));
                }
            }
Example #9
0
        /// <summary>
        /// Records the specified call.
        /// </summary>
        /// <param name="fakeObjectCall">The call to record.</param>
        public virtual void RecordCall(ICompletedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");

            var callData = new CallData(fakeObjectCall.Method, GetOutputArgumentsForCall(fakeObjectCall), fakeObjectCall.ReturnValue);

            this.recordedCalls.Add(new CallDataMetadata {
                HasBeenApplied = true, RecordedCall = callData
            });
        }
Example #10
0
            protected override void OnAddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call)
            {
                List <ICompletedFakeObjectCall> calls;

                if (!this.recordedCalls.TryGetValue(fakeObject, out calls))
                {
                    calls = new List <ICompletedFakeObjectCall>();
                    this.recordedCalls.Add(fakeObject, calls);
                }

                calls.Add(call);
            }
Example #11
0
            protected override void OnAddInterceptedCall(FakeManager fakeManager, ICompletedFakeObjectCall call)
            {
                this.parentScope.OnAddInterceptedCall(fakeManager, call);

                this.recordedCalls.AddLast(call);

                List <ICompletedFakeObjectCall> calls;

                if (!this.recordedCallsGroupedByFakeManager.TryGetValue(fakeManager, out calls))
                {
                    calls = new List <ICompletedFakeObjectCall>();
                    this.recordedCallsGroupedByFakeManager.Add(fakeManager, calls);
                }

                calls.Add(call);
            }
Example #12
0
        public static void RecordedCallHasReturnValue(
            IFoo fake,
            object returnValue,
            ICompletedFakeObjectCall recordedCall)
        {
            "Given a fake"
            .x(() => fake = A.Fake <IFoo>());

            "When I call a method on the fake"
            .x(() => returnValue = fake.AMethodReturningAnObject());

            "And I retrieve the call from the recorded calls"
            .x(() => recordedCall = Fake.GetCalls(fake).Single());

            "Then the recorded call's return value should be the value that was actually returned"
            .x(() => recordedCall.ReturnValue.Should().Be(returnValue));
        }
Example #13
0
        public static void RecordedDelegateCallHasReturnValue(
            Func <object> fake,
            object returnValue,
            ICompletedFakeObjectCall recordedCall)
        {
            "Given a fake delegate"
            .x(() => fake = A.Fake <Func <object> >());

            "When I invoke the fake delegate"
            .x(() => returnValue = fake());

            "And I retrieve the call from the recorded calls"
            .x(() => recordedCall = Fake.GetCalls(fake).Single());

            "Then the recorded call's return value should be the value that was actually returned"
            .x(() => recordedCall.ReturnValue.Should().Be(returnValue));
        }
Example #14
0
        /// <summary>
        /// Records the specified call.
        /// </summary>
        /// <param name="fakeObjectCall">The call to record.</param>
        public virtual void RecordCall(ICompletedFakeObjectCall fakeObjectCall)
        {
            var hash  = fakeObjectCall.GetHashCode();
            var watch = watches[hash];

            watches.Remove(hash);
            watch.Stop();

            var callData = new CallData(fakeObjectCall.Method, CommonExtensions.GetOutputArgumentsForCall(fakeObjectCall), fakeObjectCall.ReturnValue.Copy());

            var item = new CallMetadata
            {
                HasBeenApplied = false,
                RecordedCall   = callData,
                ElapsedTime    = watch.ElapsedMilliseconds,
                UniqueId       = KeyGenerator.GetMethodKey(fakeObjectCall.FakedObject.GetType(), fakeObjectCall.Method, CommonExtensions.GetCurrentStack())
            };

            this.recordedCalls.AddItem(item);
        }
Example #15
0
 private bool CallDataMatchesCall(CallData callData, ICompletedFakeObjectCall recordedCall)
 {
     return(callData.Method.Equals(recordedCall.Method) &&
            callData.OutputArguments.SequenceEqual(new object[] { 3, "4" }) &&
            callData.ReturnValue.Equals(10));
 }
Example #16
0
 /// <summary>
 /// Adds an intercepted call to the current scope.
 /// </summary>
 /// <param name="fakeManager">The fake object.</param>
 /// <param name="call">The call that is intercepted.</param>
 internal void AddInterceptedCall(FakeManager fakeManager, ICompletedFakeObjectCall call)
 {
     fakeManager.AllRecordedCalls.Add(call);
     this.OnAddInterceptedCall(fakeManager, call);
 }
Example #17
0
 protected override void OnAddInterceptedCall(FakeManager fakeObject, ICompletedFakeObjectCall call)
 {
 }
Example #18
0
            protected override void OnAddInterceptedCall(FakeManager fakeManager, ICompletedFakeObjectCall call)
            {
                this.parentScope.OnAddInterceptedCall(fakeManager, call);

                this.recordedCalls.AddLast(call);

                List<ICompletedFakeObjectCall> calls;

                if (!this.recordedCallsGroupedByFakeManager.TryGetValue(fakeManager, out calls))
                {
                    calls = new List<ICompletedFakeObjectCall>();
                    this.recordedCallsGroupedByFakeManager.Add(fakeManager, calls);
                }

                calls.Add(call);
            }
Example #19
0
 protected abstract void OnAddInterceptedCall(FakeManager fakeObject, ICompletedFakeObjectCall call);
            public void OnAfterCallIntercepted(ICompletedFakeObjectCall call, IFakeObjectCallRule ruleThatWasApplied)
            {
                Guard.AgainstNull(call, nameof(call));

                if (call.Method.Name.Equals("TrapConstraints"))
                {
                    this.realTrap.TrapConstraints(call.GetArgument<Action>(0));
                }
            }
Example #21
0
 /// <summary>
 /// Records that a call has occurred on the managed object.
 /// </summary>
 /// <param name="call">The call to remember.</param>
 internal void RecordCall(ICompletedFakeObjectCall call)
 {
     SequenceNumberManager.RecordSequenceNumber(call);
     this.recordedCalls.Enqueue(call);
 }
Example #22
0
 /// <summary>
 /// Adds an intercepted call to the current scope.
 /// </summary>
 /// <param name="fakeManager">The fake object.</param>
 /// <param name="call">The call that is intercepted.</param>
 internal void AddInterceptedCall(FakeManager fakeManager, ICompletedFakeObjectCall call)
 {
     fakeManager.AllRecordedCalls.Add(call);
     this.OnAddInterceptedCall(fakeManager, call);
 }
Example #23
0
 protected override void OnAddInterceptedCall(FakeManager fakeObject, ICompletedFakeObjectCall call)
 {
 }
Example #24
0
 protected override void OnAddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call)
 {
     // Do nothing
 }
Example #25
0
 /// <summary>
 /// Records that a call has occurred on the managed object.
 /// </summary>
 /// <param name="call">The call to remember.</param>
 internal void RecordCall(ICompletedFakeObjectCall call)
 {
     this.recordedCalls.Enqueue(call);
 }
Example #26
0
 /// <summary>
 /// Records that a call has occurred on the managed object.
 /// </summary>
 /// <param name="call">The call to remember.</param>
 internal void RecordCall(ICompletedFakeObjectCall call)
 {
     this.recordedCalls.Enqueue(call);
 }
 public static int GetSequenceNumber(ICompletedFakeObjectCall call) => SequenceNumbers.GetOrCreateValue(call).Value;
Example #28
0
 public void OnAfterCallIntercepted(ICompletedFakeObjectCall interceptedCall, IFakeObjectCallRule ruleThatWasApplied)
 {
 }
 private bool CallDataMatchesCall(CallData callData, ICompletedFakeObjectCall recordedCall)
 {
     return callData.Method.Equals(recordedCall.Method)
         && callData.OutputArguments.SequenceEqual(new object[] { 3, "4" })
         && callData.ReturnValue.Equals(10);
 }
Example #30
0
 protected abstract void OnAddInterceptedCall(FakeManager fakeObject, ICompletedFakeObjectCall call);
Example #31
0
 public static int GetSequenceNumber(ICompletedFakeObjectCall call) => SequenceNumbers.GetOrCreateValue(call).Value;
            public void OnAfterCallIntercepted(ICompletedFakeObjectCall call, IFakeObjectCallRule ruleThatWasApplied)
            {
                Guard.AgainstNull(call, "call");

                if (call.Method.Name.Equals("TrapConstraints"))
                {
                    call.GetArgument<Action>(0).Invoke();
                }
            }
 public static T Get <T>(this ICompletedFakeObjectCall call, String argumentName)
 {
     return(call.Arguments.Get <T>(argumentName));
 }