Ejemplo n.º 1
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 });
        }
Ejemplo n.º 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
            });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 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));
 }