public IMockBehavior BehaviorFor(IMockSetup setup) => setupBehaviorMap.GetOrAdd(setup, x => { var behavior = new MockBehavior(x); Behaviors.Insert(1, behavior); return(behavior); });
public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => setupBehaviorMap.GetOrAdd(setup, x => { var behavior = new MockBehaviorPipeline(x); // The tracking behavior must appear before the mock behaviors. var tracking = Behaviors.OfType <MockTrackingBehavior>().FirstOrDefault(); // NOTE: latest setup wins, since it goes to the top of the list. var index = tracking == null ? 0 : (Behaviors.IndexOf(tracking) + 1); Behaviors.Insert(index, behavior); return(behavior); });
/// <inheritdoc /> public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => setupBehaviorMap.GetOrAdd(setup, x => { var behavior = new MockBehaviorPipeline(x); // The tracking behavior must appear before the mock behaviors. var context = Behaviors.OfType <MockContextBehavior>().FirstOrDefault(); // If there is a recording behavior, it must be before mock behaviors too. var recording = Behaviors.OfType <MockRecordingBehavior>().FirstOrDefault(); var index = context == null ? 0 : Behaviors.IndexOf(context); if (recording != null) { index = Math.Max(index, Behaviors.IndexOf(recording)); } // NOTE: latest setup wins, since it goes to the top of the list. Behaviors.Insert(++index, behavior); return(behavior); });
public bool Equals(IMockSetup other) => base.Equals(other);
/// <inheritdoc /> public bool Equals(IMockSetup other) => other != null && Invocation.Equals(other.Invocation) && Matchers.SequenceEqual(other.Matchers);
public MockBehaviorPipeline(IMockSetup setup) => Setup = setup;
/// <summary> /// Initializes the exception with the target /// mock and setup that failed to match invocations. /// </summary> public VerifyException(IMock mock, IMockSetup setup) { Mock = mock; Setup = setup; }
/// <summary> /// Initializes the exception with the target /// mock and setup that failed to match invocations. /// </summary> public VerifyException(IMock mock, IMockSetup setup, string?message = null) : this(mock, new[] { setup }, message) { }
public SomeClass(IDepencyA a, IDepencyB b, IMockSetup mock) { A = a; B = b; Mock = mock; }
public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => mock.GetPipeline(setup);
public DefaultMockBehavior(IMockSetup setup) => Setup = setup;
public MockBehavior(IMockSetup setup) => Setup = setup;
public IMockBehavior BehaviorFor(IMockSetup setup) { throw new NotImplementedException(); }
public IMockBehavior BehaviorFor(IMockSetup setup) => mock.BehaviorFor(setup);
public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => throw new NotImplementedException();