/// <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 });
        }
示例#2
0
        /// <summary>
        /// Records the specified call.
        /// </summary>
        /// <param name="fakeObjectCall">The call to record.</param>
        public virtual void RecordCall(ICompletedFakeObjectCall fakeObjectCall)
        {
            var callData = new CallData(fakeObjectCall.Method, GetOutputArgumentsForCall(fakeObjectCall), fakeObjectCall.ReturnValue);

            this.recordedCalls.Add(new CallDataMetadata {
                HasBeenApplied = true, RecordedCall = callData
            });
        }
示例#3
0
        public void CallData_should_be_serializable()
        {
            // Arrange
            var data = new CallData(this.DummyMethodInfo, Enumerable.Empty<object>(), new object());
            // Act

            // Assert
            Assert.That(data, Is.BinarySerializable);
        }
示例#4
0
        public void CallData_should_be_serializable_when_output_arguments_is_provided_by_linq_query()
        {
            // Arrange
            var outputArguments =
                (from number in Enumerable.Range(1, 10)
                 select number).Cast<object>();

            var data = new CallData(this.DummyMethodInfo, outputArguments, null);

            // Act

            // Assert
            data.Should().BeBinarySerializable();
        }
 private bool CallDataMatchesCall(CallData callData, ICompletedFakeObjectCall recordedCall)
 {
     return callData.Method.Equals(recordedCall.Method)
         && callData.OutputArguments.SequenceEqual(new object[] { 3, "4" })
         && callData.ReturnValue.Equals(10);
 }
 private static IEnumerable<Tuple<int, object>> GetIndicesAndValuesOfOutputParameters(IInterceptedFakeObjectCall call, CallData recordedCall)
 {
     return
         (from argument in call.Method.GetParameters().Zip(Enumerable.Range(0, int.MaxValue))
          where argument.Item1.ParameterType.IsByRef
          select argument.Item2).Zip(recordedCall.OutputArguments);
 }
 private static IEnumerable <Tuple <int, object> > GetIndicesAndValuesOfOutputParameters(IWritableFakeObjectCall call, CallData recordedCall)
 {
     return
         ((from argument in call.Method.GetParameters().Zip(Enumerable.Range(0, int.MaxValue))
           where argument.First.ParameterType.IsByRef
           select argument.Second).Zip(recordedCall.OutputArguments));
 }