示例#1
0
 private static void ConfirmSequenceInvocationIndices(SequenceInvocationIndices sequenceInvocationIndices)
 {
     if (sequenceInvocationIndices == null)
     {
         throw new ArgumentNullException("sequenceInvocationIndices");
     }
     if (sequenceInvocationIndices.Count == 0)
     {
         throw new ArgumentException(SequenceInvocationIndicesEmptyMessage);
     }
 }
示例#2
0
 public static IInvocableSequenceReturn SetupInSequenceShared <T, TReturn>(this Mock <T> mock, Expression <Func <T, TReturn> > setUp, ISequence sequence, ExceptionsOrReturns <TReturn> exceptionsOrReturns, SequenceInvocationIndices sequenceInvocationIndices) where T : class
 {
     sequence = sequence ?? throw new ArgumentNullException(nameof(sequence));
     return(SetupInSequenceResult(sequence, mock, setUp, exceptionsOrReturns, sequenceInvocationIndices));
 }
示例#3
0
 public static IInvocableSequenceReturn SetupInSequenceCreateShared <T, TReturn>(this Mock <T> mock, Expression <Func <T, TReturn> > setUp, out ISequence sequence, ExceptionsOrReturns <TReturn> exceptionsOrReturns, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     sequence = Sequence.Factory.CreateShared(loops);
     return(SetupInSequenceResult(sequence, mock, setUp, exceptionsOrReturns, sequenceInvocationIndices));
 }
示例#4
0
 public static IInvocableSequenceReturn SetupInSequenceSingle <T, TReturn>(this Mock <T> mock, Expression <Func <T, TReturn> > setUp, Returns <TReturn> returns, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     return(SetupInSequenceResult(Sequence.Factory.CreateSingle(mock, loops), mock, setUp, returns, sequenceInvocationIndices));
 }
示例#5
0
        private static IInvocableSequenceReturn SetupInSequenceResult <T, TReturn>(ISequence sequence, Mock <T> mock, Expression <Func <T, TReturn> > setUp, ExceptionsOrReturns <TReturn> exceptionsOrReturns, SequenceInvocationIndices sequenceInvocationIndices) where T : class
        {
            ConfirmResponsesAndSequenceInvocationIndices(exceptionsOrReturns, "exceptionsOrReturns", sequenceInvocationIndices);
            var setUpResult = mock.Setup(setUp);
            var invocable   = Invocable.Factory.CreateSequenceReturn <T, TReturn>(setUpResult, mock, sequence, exceptionsOrReturns, sequenceInvocationIndices);

            sequence.RegisterInvocable(invocable);
            return(invocable);
        }
示例#6
0
 public static ISetup <T, TResult> SetupInSequenceShared <T, TResult>(this Mock <T> mock, Expression <Func <T, TResult> > setUp, ISequence sequence, SequenceInvocationIndices sequenceInvocationIndices) where T : class
 {
     sequence = sequence ?? throw new ArgumentNullException(nameof(sequence));
     return(SetupInSequenceResult <T, TResult>(sequence, mock, setUp, sequenceInvocationIndices));
 }
示例#7
0
 public static ISetupGetter <T, TProperty> SetupGetInSequenceCreateShared <T, TProperty>(this Mock <T> mock, Expression <Func <T, TProperty> > setupGet, out ISequence sequence, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     sequence = Sequence.Factory.CreateShared(loops);
     return(SetupGetInSequence(sequence, mock, setupGet, sequenceInvocationIndices));
 }
示例#8
0
 public static IInvocableSequence SetupInSequenceCreateShared <T>(this Mock <T> mock, Expression <Action <T> > setUp, out ISequence sequence, PassOrThrows passOrThrows, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     sequence = Sequence.Factory.CreateShared(loops);
     return(SetupInSequence <T>(sequence, mock, setUp, passOrThrows, sequenceInvocationIndices));
 }
示例#9
0
 public static ISetupGetter <T, TProperty> SetupGetInSequenceShared <T, TProperty>(this Mock <T> mock, Expression <Func <T, TProperty> > setupGet, ISequence sequence, SequenceInvocationIndices sequenceInvocationIndices) where T : class
 {
     sequence = sequence ?? throw new ArgumentNullException(nameof(sequence));
     ConfirmSequenceInvocationIndices(sequenceInvocationIndices);
     return(SetupGetInSequence(sequence, mock, setupGet, sequenceInvocationIndices));
 }
示例#10
0
        private static ISetupGetter <T, TProperty> SetupGetInSequence <T, TProperty>(ISequence sequence, Mock <T> mock, Expression <Func <T, TProperty> > setupGet, SequenceInvocationIndices sequenceInvocationIndices) where T : class
        {
            ConfirmSequenceInvocationIndices(sequenceInvocationIndices);
            var setUpGetter = mock.SetupGet(setupGet);
            var invocable   = Invocable.Factory.CreateGet <T, TProperty>(setUpGetter, mock, sequence, sequenceInvocationIndices);

            sequence.RegisterInvocable(invocable);
            return(invocable);
        }
示例#11
0
 public static ISetup <T> SetupSetInSequenceCreateShared <T>(this Mock <T> mock, Action <T> setUp, out ISequence sequence, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     sequence = Sequence.Factory.CreateShared(loops);
     return(SetupSetInSequence(sequence, mock, setUp, sequenceInvocationIndices));
 }
示例#12
0
 public static ISetup <T> SetupSetInSequenceShared <T>(this Mock <T> mock, Action <T> setUp, ISequence sequence, SequenceInvocationIndices sequenceInvocationIndices) where T : class
 {
     sequence = sequence ?? throw new ArgumentNullException(nameof(sequence));
     return(SetupSetInSequence(sequence, mock, setUp, sequenceInvocationIndices));
 }
示例#13
0
 public static ISetup <T> SetupSetInSequenceSingle <T>(this Mock <T> mock, Action <T> setUp, SequenceInvocationIndices sequenceInvocationIndices, int loops = 1) where T : class
 {
     ConfirmLoops(loops);
     return(SetupSetInSequence(Sequence.Factory.CreateSingle(mock, loops), mock, setUp, sequenceInvocationIndices));
 }
示例#14
0
 public static IInvocableSequence SetupInSequenceShared <T>(this Mock <T> mock, Expression <Action <T> > setUp, ISequence sequence, PassOrThrows passOrThrows, SequenceInvocationIndices sequenceInvocationIndices) where T : class
 {
     sequence = sequence ?? throw new ArgumentNullException(nameof(sequence));
     return(SetupInSequence <T>(sequence, mock, setUp, passOrThrows, sequenceInvocationIndices));
 }
示例#15
0
 private static void ConfirmResponsesAndSequenceInvocationIndices <TResponse>(IInvocationResponses <TResponse> responses, string responsesParameterName, SequenceInvocationIndices sequenceInvocationIndices)
 {
     ConfirmResponses(responses, responsesParameterName);
     ConfirmSequenceInvocationIndices(sequenceInvocationIndices);
     if (responses.ConfiguredResponses != sequenceInvocationIndices.Count)
     {
         throw new ArgumentException(IncorrectNumberOfConfiguredResponses);
     }
 }
示例#16
0
        private static ISetup <T> SetupInSequence <T>(ISequence sequence, Mock <T> mock, Expression <Action <T> > setUp, SequenceInvocationIndices sequenceInvocationIndices) where T : class
        {
            ConfirmSequenceInvocationIndices(sequenceInvocationIndices);
            var setUpResult = mock.Setup(setUp);
            var invocable   = Invocable.Factory.CreateNoReturn <T>(setUpResult, mock, sequence, sequenceInvocationIndices);

            sequence.RegisterInvocable(invocable);
            return(invocable);
        }
示例#17
0
        private static IInvocableSequence SetupInSequence <T>(ISequence sequence, Mock <T> mock, Expression <Action <T> > setUp, PassOrThrows passOrThrows, SequenceInvocationIndices sequenceInvocationIndices) where T : class
        {
            ConfirmResponsesAndSequenceInvocationIndices(passOrThrows, "passOrThrows", sequenceInvocationIndices);
            var setUpResult = mock.Setup(setUp);
            var invocable   = Invocable.Factory.CreateSequenceNoReturn <T>(setUpResult, mock, sequence, passOrThrows, sequenceInvocationIndices);

            sequence.RegisterInvocable(invocable);
            return(invocable);
        }