public void Delete() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("","Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false",CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test"; TempObject.BoolValue = false; TempObject.FloatValue = 1.5f; TempObject.LongValue = 12; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Helper2.Save<ObjectClass1, int>(TempObject); Assert.Equal(1, Helper2.Delete<ObjectClass1>(TempObject)); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT COUNT(*) AS ItemCount FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal(0, Helper.GetParameter<int>("ItemCount", -1)); } else { Assert.False(true,"Nothing was inserted"); } } } }
public void Delete() { Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper()) { for (int x = 0; x < 100; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Save<ObjectClass1, int>(TempObject); } TempObject = null; IEnumerable<ObjectClass1> Objects = ORM.All<ObjectClass1>(); Assert.Equal(100, Objects.Count()); foreach (ObjectClass1 Object in Objects) { ORM.Delete<ObjectClass1>(Object); } Objects = ORM.All<ObjectClass1>(); Assert.Equal(0, Objects.Count()); } }