コード例 #1
0
        public void TestInvalidCommandType()
        {
            // Specify an invalid type
            var attribute = new SqlAttribute("");

            attribute.CommandType = System.Data.CommandType.TableDirect;
            Assert.Throws <ArgumentException>(() => SqlBindingUtilities.BuildCommand(attribute, null));


            // Don't specify a type at all
            attribute = new SqlAttribute("");
            Assert.Throws <ArgumentException>(() => SqlBindingUtilities.BuildCommand(attribute, null));
        }
コード例 #2
0
        public void TestValidCommandType()
        {
            var query     = "select * from Products";
            var attribute = new SqlAttribute(query);

            attribute.CommandType = System.Data.CommandType.Text;
            var command = SqlBindingUtilities.BuildCommand(attribute, null);

            Assert.Equal(System.Data.CommandType.Text, command.CommandType);
            Assert.Equal(query, command.CommandText);

            var procedure = "StoredProceudre";

            attribute             = new SqlAttribute(procedure);
            attribute.CommandType = System.Data.CommandType.StoredProcedure;
            command = SqlBindingUtilities.BuildCommand(attribute, null);
            Assert.Equal(System.Data.CommandType.StoredProcedure, command.CommandType);
            Assert.Equal(procedure, command.CommandText);
        }