Esempio n. 1
0
        public void TestTypeMapAttributeUnquotedNameViaEntityViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                var command = connection.CreateCommand();
                DbCommandExtension
                .CreateParameters(command, new TestTypeMapAttributeUnquotedNameClass
                {
                    ColumnString = "ColumnStringValue"
                });

                // Assert
                Assert.AreEqual(1, command.Parameters.Count);

                // Assert
                var parameter = command.Parameters["@ColumnString"];
                Assert.AreEqual(DbType.StringFixedLength, parameter.DbType);
            }
        }
Esempio n. 2
0
        public void TestColumnAttributeUnquotedNameViaEntityViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                var command = connection.CreateCommand();
                DbCommandExtension
                .CreateParameters(command, new TestColumnAttributeUnquotedNameClass
                {
                    Id = 1
                });

                // Assert
                Assert.AreEqual(1, command.Parameters.Count);

                // Assert
                var parameter = command.Parameters["@PrimaryId"];
                Assert.IsNotNull(parameter);
            }
        }
Esempio n. 3
0
        public void TestPropertyValueAttributeViaDerivedClassViaEntityViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    DbCommandExtension
                    .CreateParameters(command, new PropertyValueAttributeViaDerivedTestClass
                    {
                        ColumnName = "Test"
                    });

                    // Assert
                    Assert.AreEqual(1, command.Parameters.Count);

                    // Assert
                    var parameter = command.Parameters["@ColumnName"];
                    Assert.AreEqual("ValueOfTag", ((CustomDbParameter)parameter).Tag);
                }
            }
        }
        public void TestIsNullableAttributeViaEntityViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    DbCommandExtension
                    .CreateParameters(command, new IsNullableAttributeTestClass
                    {
                        ColumnName = "Test"
                    });

                    // Assert
                    Assert.AreEqual(1, command.Parameters.Count);

                    // Assert
                    var parameter = command.Parameters["@ColumnName"];
                    Assert.AreEqual(true, ((CustomDbParameter)parameter).IsNullable);
                }
            }
        }
Esempio n. 5
0
        public void TestDbTypeAttributeViaEntityViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    DbCommandExtension
                    .CreateParameters(command, new DbTypeAttributeTestClass
                    {
                        ColumnName = "Test"
                    });

                    // Assert
                    Assert.AreEqual(1, command.Parameters.Count);

                    // Assert
                    var parameter = command.Parameters["@ColumnName"];
                    Assert.AreEqual(DbType.AnsiStringFixedLength, ((CustomDbParameter)parameter).DbType);
                }
            }
        }
        public void TestDirectionAttributeViaAnonymousViaCreateParameters()
        {
            // Act
            using (var connection = new CustomDbConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    DbCommandExtension
                    .CreateParameters(command, new
                    {
                        ColumnName = "Test"
                    },
                                      typeof(DirectionAttributeTestClass));

                    // Assert
                    Assert.AreEqual(1, command.Parameters.Count);

                    // Assert
                    var parameter = command.Parameters["@ColumnName"];
                    Assert.AreEqual(ParameterDirection.Output, ((CustomDbParameter)parameter).Direction);
                }
            }
        }