AddParameter() public static method

Add a parameter to a command
public static AddParameter ( this command, string name, object value ) : IDataParameter
command this Command to add parameter to
name string Name of the parameter
value object Value (will be changed to DBNull.Value automatically if it's null).
return IDataParameter
Exemplo n.º 1
0
        public void do_not_allow_name_to_be_null()
        {
            var    sut    = new FakeCommand();
            Action actual = () => CommandExtensions.AddParameter(sut, null, "arne");

            actual.ShouldThrow <ArgumentNullException>();
        }
        public void cant_operate_if_supplied_argument_do_not_specify_a_name()
        {
            var    sut    = new FakeCommand();
            Action actual = () => CommandExtensions.AddParameter(sut, null, "arne");

            actual.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 3
0
        public void convert_null_value_to_dbnull()
        {
            var sut = new FakeCommand();

            CommandExtensions.AddParameter(sut, "name", null);

            sut.Parameters[0].Value.Should().Be(DBNull.Value);
        }
Exemplo n.º 4
0
        public void add_created_parameter_to_command()
        {
            var sut = new FakeCommand();

            CommandExtensions.AddParameter(sut, "name", "arne");

            sut.Parameters[0].Value.Should().Be("arne");
            sut.Parameters[0].ParameterName.Should().Be("name");
        }