Esempio n. 1
0
 public IMockBehavior BehaviorFor(IMockSetup setup)
 => setupBehaviorMap.GetOrAdd(setup, x =>
 {
     var behavior = new MockBehavior(x);
     Behaviors.Insert(1, behavior);
     return(behavior);
 });
Esempio n. 2
0
 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);
 });
Esempio n. 3
0
        /// <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);
        });
Esempio n. 4
0
 public bool Equals(IMockSetup other) => base.Equals(other);
Esempio n. 5
0
 /// <inheritdoc />
 public bool Equals(IMockSetup other)
 => other != null && Invocation.Equals(other.Invocation) && Matchers.SequenceEqual(other.Matchers);
Esempio n. 6
0
 public MockBehaviorPipeline(IMockSetup setup) => Setup = setup;
Esempio n. 7
0
 /// <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;
 }
Esempio n. 8
0
 /// <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)
 {
 }
Esempio n. 9
0
 public SomeClass(IDepencyA a, IDepencyB b, IMockSetup mock)
 {
     A    = a;
     B    = b;
     Mock = mock;
 }
Esempio n. 10
0
 public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => mock.GetPipeline(setup);
Esempio n. 11
0
 public DefaultMockBehavior(IMockSetup setup) => Setup = setup;
Esempio n. 12
0
 public MockBehavior(IMockSetup setup) => Setup = setup;
Esempio n. 13
0
 public IMockBehavior BehaviorFor(IMockSetup setup)
 {
     throw new NotImplementedException();
 }
Esempio n. 14
0
 public IMockBehavior BehaviorFor(IMockSetup setup) => mock.BehaviorFor(setup);
Esempio n. 15
0
 public IMockBehaviorPipeline GetPipeline(IMockSetup setup) => throw new NotImplementedException();