public ConfiguredCall SetResultForLastCall(IReturn valueToReturn, MatchArgs matchArgs) { var spec = _getCallSpec.FromPendingSpecification(matchArgs); CheckResultIsCompatibleWithCall(valueToReturn, spec); _configuredResults.SetResult(spec, valueToReturn); return new ConfiguredCall(action => _callActions.Add(spec, action)); }
public SetActionForCallHandler(ICallSpecificationFactory callSpecificationFactory, ICallActions callActions, Action<CallInfo> action, MatchArgs matchArgs) { _callSpecificationFactory = callSpecificationFactory; _callActions = callActions; _action = action; _matchArgs = matchArgs; }
public CheckDidNotReceiveCallHandler(IReceivedCalls receivedCalls, ICallSpecificationFactory callSpecificationFactory, ICallReceivedExceptionThrower exceptionThrower, MatchArgs matchArgs) { _receivedCalls = receivedCalls; _callSpecificationFactory = callSpecificationFactory; _exceptionThrower = exceptionThrower; _matchArgs = matchArgs; }
public CheckReceivedCallsHandler(IReceivedCalls receivedCalls, ICallSpecificationFactory callSpecificationFactory, IReceivedCallsExceptionThrower exceptionThrower, MatchArgs matchArgs, Quantity requiredQuantity) { _receivedCalls = receivedCalls; _callSpecificationFactory = callSpecificationFactory; _exceptionThrower = exceptionThrower; _matchArgs = matchArgs; _requiredQuantity = requiredQuantity; }
public IRoute DoWhenCalled(ISubstituteState state, Action<CallInfo> doAction, MatchArgs matchArgs) { return new Route(new ICallHandler[] { new ClearLastCallRouterHandler(state.SubstitutionContext) , new ClearUnusedCallSpecHandler(state) , new SetActionForCallHandler(state.CallSpecificationFactory, state.CallActions, doAction, matchArgs) , ReturnDefaultForReturnTypeHandler() }); }
public IRoute DoNotCallBase(ISubstituteState state, MatchArgs matchArgs) { return new Route(new ICallHandler[] { new ClearLastCallRouterHandler(state.SubstitutionContext) , new ClearUnusedCallSpecHandler(state.PendingSpecification) , new DoNotCallBaseForCallHandler(state.CallSpecificationFactory, state.CallBaseExclusions, matchArgs) , ReturnDefaultForReturnTypeHandler() }); }
public ICallSpecification CreateFrom(ICall call, MatchArgs matchArgs) { var methodInfo = call.GetMethodInfo(); var argumentSpecs = call.GetArgumentSpecifications(); var arguments = call.GetOriginalArguments(); var parameterInfos = call.GetParameterInfos(); var argumentSpecificationsForCall = _argumentSpecificationsFactory.Create(argumentSpecs, arguments, parameterInfos, matchArgs); return new CallSpecification(methodInfo, argumentSpecificationsForCall); }
public void LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) { throw new CouldNotSetReturnException(); } _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); _lastCallRouter.Value = null; }
public IRoute CheckReceivedCalls(ISubstituteState state, MatchArgs matchArgs, Quantity requiredQuantity) { return new Route(new ICallHandler[] { new ClearLastCallRouterHandler(state.SubstitutionContext) , new ClearUnusedCallSpecHandler(state) , new CheckReceivedCallsHandler(state.ReceivedCalls, state.CallSpecificationFactory, new ReceivedCallsExceptionThrower(), matchArgs, requiredQuantity) , ReturnDefaultForReturnTypeHandler() }); }
public ICallSpecification FromPendingSpecification(MatchArgs matchArgs, PendingSpecificationInfo pendingSpecInfo) { return(pendingSpecInfo.Handle( callSpec => FromExistingSpec(callSpec, matchArgs), lastCall => { _receivedCalls.Delete(lastCall); return FromCall(lastCall, matchArgs); })); }
public IRoute CheckReceivedCalls(ISubstituteState state, MatchArgs matchArgs, Quantity requiredQuantity) { return new Route(new ICallHandler[] { new ClearLastCallRouterHandler(state.SubstitutionContext) , new ClearUnusedCallSpecHandler(state.PendingSpecification) , new CheckReceivedCallsHandler(state.ReceivedCalls, state.CallSpecificationFactory, new ReceivedCallsExceptionThrower(), matchArgs, requiredQuantity) , new ReturnAutoValue(AutoValueBehaviour.ReturnAndForgetValue, state.AutoValueProviders, state.AutoValuesCallResults, state.CallSpecificationFactory) , ReturnDefaultForReturnTypeHandler() }); }
public ICallSpecification CreateFrom(ICall call, MatchArgs matchArgs) { var methodInfo = call.GetMethodInfo(); var argumentSpecs = call.GetArgumentSpecifications(); var arguments = call.GetOriginalArguments(); var parameterInfos = call.GetParameterInfos(); var argumentSpecificationsForCall = _argumentSpecificationsFactory.Create(argumentSpecs, arguments, parameterInfos, methodInfo, matchArgs); return(new CallSpecification(methodInfo, argumentSpecificationsForCall)); }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) { throw new CouldNotSetReturnDueToNoLastCallException(); } var configuredCall = _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); ClearLastCallRouter(); return(configuredCall); }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) throw new CouldNotSetReturnDueToNoLastCallException(); if (_argumentSpecifications.Value.Any()) { //Clear invalid arg specs so they will not affect other tests _argumentSpecifications.Value.Clear(); throw new UnexpectedArgumentMatcherException(); } var configuredCall = _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); ClearLastCallRouter(); return configuredCall; }
public ICallSpecification FromPendingSpecification(MatchArgs matchArgs, PendingSpecificationInfo pendingSpecInfo) { if (pendingSpecInfo == null) { throw new ArgumentNullException(nameof(pendingSpecInfo)); } return(pendingSpecInfo.Handle( callSpec => FromExistingSpec(callSpec, matchArgs), lastCall => { _receivedCalls.Delete(lastCall); return FromCall(lastCall, matchArgs); })); }
public ICallSpecification FromPendingSpecification(MatchArgs matchArgs) { if (!_pendingSpecification.HasPendingCallSpecInfo()) { throw new InvalidOperationException("No pending specification or previous call info."); } var pendingSpecInfo = _pendingSpecification.UseCallSpecInfo(); return pendingSpecInfo.Handle( callSpec => FromExistingSpec(callSpec, matchArgs), lastCall => { _callCollection.Delete(lastCall); return FromCall(lastCall, matchArgs); }); }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) { throw new CouldNotSetReturnDueToNoLastCallException(); } if (_argumentSpecifications.Value.Any()) { //Clear invalid arg specs so they will not affect other tests _argumentSpecifications.Value.Clear(); throw new UnexpectedArgumentMatcherException(); } var configuredCall = _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); ClearLastCallRouter(); return(configuredCall); }
public ICallSpecification FromPendingSpecification(MatchArgs matchArgs) { if (!_pendingSpecification.HasPendingCallSpecInfo()) { throw new InvalidOperationException("No pending specification or previous call info."); } var pendingSpecInfo = _pendingSpecification.UseCallSpecInfo(); return(pendingSpecInfo.Handle( callSpec => FromExistingSpec(callSpec, matchArgs), lastCall => { _callCollection.Delete(lastCall); return FromCall(lastCall, matchArgs); })); }
public ConfiguredCall LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs, PendingSpecificationInfo pendingSpecInfo) { if (returnValue == null) { throw new ArgumentNullException(nameof(returnValue)); } if (matchArgs == null) { throw new ArgumentNullException(nameof(matchArgs)); } if (pendingSpecInfo == null) { throw new ArgumentNullException(nameof(pendingSpecInfo)); } return(_substituteState.ConfigureCall.SetResultForLastCall(returnValue, matchArgs, pendingSpecInfo)); }
public ConfiguredCall LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs) { return new ConfiguredCall(x => { }); }
public void LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) throw new CouldNotSetReturnException(); _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); _lastCallRouter.Value = null; }
public ICallSpecification FromExistingSpec(ICallSpecification spec, MatchArgs matchArgs) { return(matchArgs == MatchArgs.AsSpecifiedInCall ? spec : UpdateCallSpecToMatchAnyArgs(spec)); }
public WhenCalled(ISubstitutionContext context, T substitute, Action <T> call, MatchArgs matchArgs) { _substitute = substitute; _call = call; _matchArgs = matchArgs; _callRouter = context.GetCallRouterFor(substitute); }
public ConfiguredCall LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs) { return ConfigureCall.SetResultForLastCall(returnValue, matchArgs); }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) => ThreadContext.LastCallShouldReturn(value, matchArgs);
public IRoute CallBase(ISubstituteState state, MatchArgs matchArgs) => _factory.CallBase(state, matchArgs);
public void SetResultForCall(ICall call, IReturn valueToReturn, MatchArgs matchArgs) { var spec = _getCallSpec.FromCall(call, matchArgs); CheckResultIsCompatibleWithCall(valueToReturn, spec); _configuredResults.SetResult(spec, valueToReturn); }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { return innerContext.LastCallShouldReturn(value, matchArgs); }
public DoNotCallBaseForCallHandler(ICallSpecificationFactory callSpecificationFactory, ICallBaseExclusions exclusions, MatchArgs matchArgs) { _callSpecificationFactory = callSpecificationFactory; _exclusions = exclusions; _matchArgs = matchArgs; }
public ConfiguredCall LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter.Value == null) throw new CouldNotSetReturnDueToNoLastCallException(); var configuredCall = _lastCallRouter.Value.LastCallShouldReturn(value, matchArgs); ClearLastCallRouter(); return configuredCall; }
public void LastCallShouldReturn(IReturn value, MatchArgs matchArgs) { if (_lastCallRouter == null) throw new SubstituteException(); _lastCallRouter.LastCallShouldReturn(value, matchArgs); }
public IRoute CheckReceivedCalls(ISubstituteState state, MatchArgs matchArgs, Quantity requiredQuantity) => _factory.CheckReceivedCalls(state, matchArgs, requiredQuantity);
public void LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs) { _resultSetter.SetResultForLastCall(returnValue, matchArgs); }
public IRoute DoWhenCalled(ISubstituteState state, Action <CallInfo> doAction, MatchArgs matchArgs) => _factory.DoWhenCalled(state, doAction, matchArgs);
public ConfiguredCall LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs) { return(ConfigureCall.SetResultForLastCall(returnValue, matchArgs)); }
public ICallSpecification FromCall(ICall call, MatchArgs matchArgs) { return _callSpecificationFactory.CreateFrom(call, matchArgs); }
public ICallSpecification FromExistingSpec(ICallSpecification spec, MatchArgs matchArgs) { return matchArgs == MatchArgs.AsSpecifiedInCall ? spec : UpdateCallSpecToMatchAnyArgs(spec); }
public ICallSpecification FromCall(ICall call, MatchArgs matchArgs) { return(_callSpecificationFactory.CreateFrom(call, matchArgs)); }
public WhenCalled(ISubstitutionContext context, T substitute, Action <T> call, MatchArgs matchArgs) { _substitute = substitute; _call = call; _matchArgs = matchArgs; _callRouter = context.GetCallRouterFor(substitute !); _routeFactory = context.RouteFactory; _threadContext = context.ThreadContext; }
public void LastCallShouldReturn(IReturn returnValue, MatchArgs matchArgs) { }