示例#1
0
        public void CreateSqlConnection()
        {
            IDataService  service    = new SqlClientDataService();
            IDbConnection connection = service.CreateConnection(SqlConnection);

            Assert.IsNotNull(connection);
            Assert.IsInstanceOfType(connection, typeof(SqlConnection));
            Assert.AreEqual(SqlConnection, connection.ConnectionString);
        }
示例#2
0
        public void CreateSqlSPCommand()
        {
            IDataService  service    = new SqlClientDataService();
            IDbConnection connection = service.CreateConnection(SqlConnection);
            IDbCommand    command    = service.CreateSPCommand(SPName, connection);

            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(SqlCommand));
            Assert.AreEqual(SPName, command.CommandText);
            Assert.AreEqual(CommandType.StoredProcedure, command.CommandType);
        }
示例#3
0
        public void CreateSqlTextCommand()
        {
            IDataService  service    = new SqlClientDataService();
            IDbConnection connection = service.CreateConnection(SqlConnection);
            IDbCommand    command    = service.CreateTextCommand(SelectText, connection);

            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(SqlCommand));
            Assert.AreEqual(SelectText, command.CommandText);
            Assert.AreEqual(CommandType.Text, command.CommandType);
        }
示例#4
0
        public void CreateSqlInputParameter()
        {
            IDataService     service    = new SqlClientDataService();
            IDbConnection    connection = service.CreateConnection(SqlConnection);
            IDbDataParameter parameter  = service.CreateInputParameter("Id", 1);

            Assert.IsNotNull(parameter);
            Assert.IsInstanceOfType(parameter, typeof(SqlParameter));
            Assert.AreEqual("@Id", parameter.ParameterName);
            Assert.AreEqual(1, parameter.Value);
            Assert.AreEqual(ParameterDirection.Input, parameter.Direction);
        }