Ejemplo n.º 1
0
        public void CommandInsertNullString()
        {
            Guid TempGuid = Guid.NewGuid();

            Utilities.SQL.Command TempCommand = new Utilities.SQL.Command("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", null, 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid);
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper(TempCommand, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
            {
                Helper.ExecuteNonQuery();
            }
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
            {
                Helper.ExecuteReader();
                if (Helper.Read())
                {
                    Assert.Equal("Test String", Helper.GetParameter <string>("StringValue1", ""));
                    Assert.Equal("This is a null string", Helper.GetParameter <string>("StringValue2", "This is a null string"));
                    Assert.Equal(12345, Helper.GetParameter <long>("BigIntValue", 0));
                    Assert.Equal(true, Helper.GetParameter <bool>("BitValue", false));
                    Assert.Equal(1234.5678m, Helper.GetParameter <decimal>("DecimalValue", 0));
                    Assert.Equal(12345.6534f, Helper.GetParameter <float>("FloatValue", 0));
                    Assert.Equal(TempGuid, Helper.GetParameter <Guid>("GUIDValue", Guid.Empty));
                    Assert.Equal(new DateTime(1999, 12, 31), Helper.GetParameter <DateTime>("DateTimeValue", DateTime.Now));
                }
                else
                {
                    Assert.False(true, "Nothing was inserted");
                }
            }
        }
Ejemplo n.º 2
0
 public void Creation()
 {
     Utilities.SQL.Command Object = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Assert.Equal("SELECT * FROM Table", Object.SQLCommand);
     Assert.Equal(CommandType.Text, Object.CommandType);
     Assert.Contains(0, Object.Parameters);
     Assert.Contains(1, Object.Parameters);
     Assert.Contains(2, Object.Parameters);
     Assert.Contains(3, Object.Parameters);
 }
Ejemplo n.º 3
0
 public void Creation()
 {
     Utilities.SQL.Command Object = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Assert.Equal("SELECT * FROM Table", Object.SQLCommand);
     Assert.Equal(CommandType.Text, Object.CommandType);
     Assert.Contains(0, Object.Parameters);
     Assert.Contains(1, Object.Parameters);
     Assert.Contains(2, Object.Parameters);
     Assert.Contains(3, Object.Parameters);
 }
Ejemplo n.º 4
0
 public void Equality()
 {
     Utilities.SQL.Command Object1 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Utilities.SQL.Command Object2 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Utilities.SQL.Command Object3 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2);
     Utilities.SQL.Command Object4 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1);
     Utilities.SQL.Command Object5 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0);
     Utilities.SQL.Command Object6 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text);
     Utilities.SQL.Command Object7 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.StoredProcedure, 0, 1, 2, 3);
     Utilities.SQL.Command Object8 = new Utilities.SQL.Command("SELECT * FROM Table2", CommandType.Text, 0, 1, 2, 3);
     Assert.Equal(Object1, Object2);
     Assert.NotEqual(Object1, Object3);
     Assert.NotEqual(Object1, Object4);
     Assert.NotEqual(Object1, Object5);
     Assert.NotEqual(Object1, Object6);
     Assert.NotEqual(Object1, Object7);
     Assert.NotEqual(Object1, Object8);
 }
Ejemplo n.º 5
0
 public void Equality()
 {
     Utilities.SQL.Command Object1 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Utilities.SQL.Command Object2 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2, 3);
     Utilities.SQL.Command Object3 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1, 2);
     Utilities.SQL.Command Object4 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0, 1);
     Utilities.SQL.Command Object5 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 0);
     Utilities.SQL.Command Object6 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text);
     Utilities.SQL.Command Object7 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.StoredProcedure, 0, 1, 2, 3);
     Utilities.SQL.Command Object8 = new Utilities.SQL.Command("SELECT * FROM Table2", CommandType.Text, 0, 1, 2, 3);
     Assert.Equal(Object1, Object2);
     Assert.NotEqual(Object1, Object3);
     Assert.NotEqual(Object1, Object4);
     Assert.NotEqual(Object1, Object5);
     Assert.NotEqual(Object1, Object6);
     Assert.NotEqual(Object1, Object7);
     Assert.NotEqual(Object1, Object8);
 }
Ejemplo n.º 6
0
 public void Equality2()
 {
     Utilities.SQL.Command Object1 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 1, 1);
     Utilities.SQL.Command Object2 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 1, 2);
     Assert.NotEqual(Object1, Object2);
 }
 public void CommandInsertNullString()
 {
     Guid TempGuid = Guid.NewGuid();
     Utilities.SQL.Command TempCommand = new Utilities.SQL.Command("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", null, 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid);
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper(TempCommand, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
     {
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.ExecuteReader();
         if (Helper.Read())
         {
             Assert.Equal("Test String", Helper.GetParameter<string>("StringValue1", ""));
             Assert.Equal("This is a null string", Helper.GetParameter<string>("StringValue2", "This is a null string"));
             Assert.Equal(12345, Helper.GetParameter<long>("BigIntValue", 0));
             Assert.Equal(true, Helper.GetParameter<bool>("BitValue", false));
             Assert.Equal(1234.5678m, Helper.GetParameter<decimal>("DecimalValue", 0));
             Assert.Equal(12345.6534f, Helper.GetParameter<float>("FloatValue", 0));
             Assert.Equal(TempGuid, Helper.GetParameter<Guid>("GUIDValue", Guid.Empty));
             Assert.Equal(new DateTime(1999, 12, 31), Helper.GetParameter<DateTime>("DateTimeValue", DateTime.Now));
         }
         else
         {
             Assert.Fail("Nothing was inserted");
         }
     }
 }
Ejemplo n.º 8
0
 public void Equality2()
 {
     Utilities.SQL.Command Object1 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 1, 1);
     Utilities.SQL.Command Object2 = new Utilities.SQL.Command("SELECT * FROM Table", CommandType.Text, 1, 2);
     Assert.NotEqual(Object1, Object2);
 }