/// <summary> /// Inserts a behavior into the mock behasvior pipeline at the specified /// index. /// </summary> public static void InsertMockBehavior(this object mock, int index, IMockBehavior behavior) { if (mock is IMocked target) { target.Mock.Behaviors.Insert(index, behavior); } else { throw new ArgumentException(nameof(mock)); } }
/// <summary> /// Adds a behavior to a mock. /// </summary> public static void AddMockBehavior(this object mock, IMockBehavior behavior) { if (mock is IMocked target) { target.Mock.Behaviors.Add(behavior); } else { throw new ArgumentException(nameof(mock)); } }
/// <summary> /// Adds a behavior to a mock. /// </summary> public static TMock AddBehavior <TMock>(this TMock mock, IMockBehavior behavior) { if (mock is IMocked mocked) { mocked.Mock.Behaviors.Add(behavior); } else { throw new ArgumentException(nameof(mock)); } return(mock); }
/// <summary> /// Inserts a behavior into the mock behasvior pipeline at the specified /// index. /// </summary> public static TMock InsertBehavior <TMock>(this TMock mock, int index, IMockBehavior behavior) { if (mock is IMocked mocked) { mocked.Mock.Behaviors.Insert(index, behavior); } else { throw new ArgumentException(nameof(mock)); } return(mock); }
public static string ToString(IMockBehavior behavior) { return string.Format ( "{0}(#{1}, {2}, {3})", behavior.GetName(), behavior.Priority, behavior.DescribeAllowMultiple(), behavior.DescribeInherited() ); }
/// <summary> /// Creates a new instance of the <see cref="CallBehavior{TMock}"/> type. /// </summary> /// <param name="arrangements"> The collection of arrangements that have been made for the associated mock. </param> /// <param name="signature"> The mocked method or property setter call. </param> /// <param name="mockBehavior"> The parent <see cref="IMockBehavior{TMock}"/> that created this instance. </param> public CallBehavior(IArrangementCollection arrangements, MethodInfo signature, IMockBehavior <TMock> mockBehavior) { Arrangements = arrangements ?? throw new ArgumentNullException(nameof(arrangements)); Signature = signature ?? throw new ArgumentNullException(nameof(signature)); MockBehavior = mockBehavior ?? throw new ArgumentNullException(nameof(mockBehavior)); }