/// <summary> /// Enqueue a command which should be returned by <see cref="CreateCommand"/>. /// </summary> /// <param name="command"></param> /// <remarks>You can enqueue several commands, just invoke this method several times.</remarks> public void Setup(FakeCommand command) { if (command == null) { throw new ArgumentNullException("command"); } _commandsToReturn.Enqueue(command); }
/// <summary> /// Create a new reader /// </summary> /// <param name="fakeCommand">Command which must return a new reader (by <see cref="IDbCommand.ExecuteReader()"/>)</param> /// <returns>A new reader</returns> /// <remarks>Default implementation will first try to invoke <see cref="ReaderFactory"/> and then invoke <see cref="TableFactory"/> to get a new result. /// </remarks> public virtual FakeDataReader CreateReader(FakeCommand fakeCommand) { if (ReaderFactory != null) { return(ReaderFactory(fakeCommand)); } if (TableFactory == null) { throw new InvalidOperationException("Either configure the command using command.Setup() or configure the Factory.TableFactory or Factory.ReaderFactory."); } return(new FakeDataReader(TableFactory(fakeCommand))); }
/// <summary> /// Create a new parameter. /// </summary> /// <param name="command">The command which creates a parameter.</param> /// <returns>New parameter</returns> public virtual IDbDataParameter CreateParameter(FakeCommand command) { return(new FakeParameter()); }
/// <summary> /// Creates a new parameter collection. /// </summary> /// <param name="command">The command that wants to use a new parameter collection.</param> /// <returns>Created collection</returns> public virtual ParameterCollection CreateParameterCollection(FakeCommand command) { return(new ParameterCollection(command)); }
/// <summary> /// Creates result for a <see cref="FakeCommand.ExecuteNonQuery"/>. /// </summary> /// <param name="command">Command which is executed</param> /// <returns>Default is 1</returns> public int CreateNonQueryResult(FakeCommand command) { return(1); }
/// <summary> /// Creates scalar result for a <see cref="FakeCommand.ExecuteScalar"/>. /// </summary> /// <param name="command">The command.</param> /// <param name="parameters">The parameters.</param> /// <returns>Created result, default is null</returns> public object CreateScalarResult(FakeCommand command, ParameterCollection parameters) { return(null); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterCollection"/> class. /// </summary> /// <param name="command">The commandResult.</param> public ParameterCollection(FakeCommand command) { Command = command; }
/// <summary> /// Initializes a new instance of the <see cref="CommandValidationException" /> class. /// </summary> /// <param name="errorMessage">Tells why validation failed.</param> /// <param name="command">Command that failed.</param> public CommandValidationException(string errorMessage, FakeCommand command) : base(errorMessage) { Command = command; }