コード例 #1
0
ファイル: MockCommand.cs プロジェクト: stgwilli/structuremap
        public object this[string parameterName]
        {
            get
            {
                if (_currentExpectation != null)
                {
                    if (_currentExpectation.IsOutput(parameterName))
                    {
                        return(_currentExpectation.GetOutput(parameterName));
                    }
                }

                if (_inputs.Contains(parameterName))
                {
                    return(_inputs[parameterName]);
                }

                if (_expectations.Count > 0)
                {
                    var nextExpectation = (CommandExpectation)_expectations.Peek();
                    if (nextExpectation.IsOutput(parameterName))
                    {
                        throw new NotExecutedCommandException(parameterName, Name);
                    }
                }

                throw new UnKnownOrNotSetParameterException(parameterName);
            }
            set { _inputs[parameterName] = value; }
        }