Example #1
0
        public void Delete()
        {
            using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
            {
                TestObject.Map(x => x.ID, "ID_")
                .Map(x => x.StringValue, "StringValue_", 100)
                .Map(x => x.FloatValue, "FloatValue_")
                .Map(x => x.BoolValue, "BoolValue_")
                .Map(x => x.LongValue, "LongValue_")
                .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
                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));
                TestObject.Save <int>(TempObject);
                Assert.Equal(1, TestObject.Delete(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");
                    }
                }
            }
        }
Example #2
0
 public void Any()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_")
         .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand       = new Utilities.Random.Random(12345);
         ObjectClass1            TempObject = new ObjectClass1();
         TempObject.StringValue    = "Test String";
         TempObject.BoolValue      = true;
         TempObject.FloatValue     = 1234.5f;
         TempObject.LongValue      = 12345;
         TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
         string StringMaxValue = TempObject.StringMaxValue;
         TestObject.Save <int>(TempObject);
         TempObject = TestObject.Any();
         Assert.Equal("Test String", TempObject.StringValue);
         Assert.Equal(1234.5f, TempObject.FloatValue);
         Assert.Equal(true, TempObject.BoolValue);
         Assert.Equal(12345, TempObject.LongValue);
         Assert.Equal(1, TempObject.ID);
         Assert.Equal(StringMaxValue, TempObject.StringMaxValue);
     }
 }
Example #3
0
 public void Scalar()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_")
         .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand = new Utilities.Random.Random(12345);
         for (int x = 0; x < 100; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue    = "Test String";
             TempObject.BoolValue      = true;
             TempObject.FloatValue     = 1234.5f;
             TempObject.LongValue      = 12345;
             TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
             string StringMaxValue = TempObject.StringMaxValue;
             TestObject.Save <int>(TempObject);
         }
         int ASD = TestObject.Scalar <int>("SELECT COUNT(*) FROM TestTable", CommandType.Text);
         Assert.Equal(100, ASD);
         ASD = TestObject.Scalar <int>("COUNT(*)");
         Assert.Equal(100, ASD);
     }
 }
Example #4
0
 public void Paged()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_");
         List <ObjectClass1>     Objects2 = new List <ObjectClass1>();
         Utilities.Random.Random Rand     = new Utilities.Random.Random();
         for (int x = 0; x < 115; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue = Rand.NextString(10);
             TempObject.BoolValue   = Rand.NextBool();
             TempObject.FloatValue  = (float)Rand.NextDouble();
             TempObject.LongValue   = Rand.Next(0, 100);
             Objects2.Add(TempObject);
         }
         TestObject.Save <int>(Objects2);
         IEnumerable <ObjectClass1> Objects = TestObject.Paged();
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 1);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 2);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 3);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 4);
         Assert.Equal(15, Objects.Count());
         Assert.Equal(5, TestObject.PageCount());
     }
 }
Example #5
0
 public void All()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_")
         .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand       = new Utilities.Random.Random(12345);
         ObjectClass1            TempObject = new ObjectClass1();
         TempObject.StringValue    = "Test String";
         TempObject.BoolValue      = true;
         TempObject.FloatValue     = 1234.5f;
         TempObject.LongValue      = 12345;
         TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
         TestObject.Save <int>(TempObject);
         IEnumerable <ObjectClass1> Objects = TestObject.All();
         Assert.Equal(1, Objects.Count());
         foreach (ObjectClass1 Item in Objects)
         {
             Assert.Equal("Test String", Item.StringValue);
             Assert.Equal(1234.5f, Item.FloatValue);
             Assert.Equal(true, Item.BoolValue);
             Assert.Equal(12345, Item.LongValue);
             Assert.Equal(1, Item.ID);
             Assert.Equal(TempObject.StringMaxValue, Item.StringMaxValue);
         }
         List <ObjectClass1> Objects2 = new List <ObjectClass1>();
         Rand = new Utilities.Random.Random();
         for (int x = 0; x < 10; ++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(0, 100);
             TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
             Objects2.Add(TempObject);
         }
         TestObject.Save <int>(Objects2);
         Objects = TestObject.All();
         Assert.Equal(11, Objects.Count());
     }
 }
 public void Save()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_")
         .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand       = new Utilities.Random.Random(12346);
         ObjectClass1            TempObject = new ObjectClass1();
         TempObject.StringValue    = "Test";
         TempObject.BoolValue      = false;
         TempObject.FloatValue     = 1.5f;
         TempObject.LongValue      = 12;
         TempObject.StringMaxValue = Rand.NextString(6000);
         TestObject.Save <int>(TempObject);
         Rand = new Utilities.Random.Random(12345);
         TempObject.StringValue    = "Test String";
         TempObject.BoolValue      = true;
         TempObject.FloatValue     = 1234.5f;
         TempObject.LongValue      = 12345;
         TempObject.StringMaxValue = Rand.NextString(6000);
         TestObject.Save <int>(TempObject);
         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>("StringValue_", ""));
                 Assert.Equal(1234.5f, Helper.GetParameter <float>("FloatValue_", 0));
                 Assert.Equal(true, Helper.GetParameter <bool>("BoolValue_", false));
                 Assert.Equal(12345, Helper.GetParameter <long>("LongValue_", 0));
                 Assert.Equal(TempObject.ID, Helper.GetParameter <int>("ID_", 0));
                 Assert.Equal(TempObject.StringMaxValue, Helper.GetParameter <string>("StringMaxValue_", ""));
             }
             else
             {
                 Assert.Fail("Nothing was inserted");
             }
         }
     }
 }
 public void All()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_")
             .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand = new Utilities.Random.Random(12345);
         ObjectClass1 TempObject = new ObjectClass1();
         TempObject.StringValue = "Test String";
         TempObject.BoolValue = true;
         TempObject.FloatValue = 1234.5f;
         TempObject.LongValue = 12345;
         TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
         TestObject.Save<int>(TempObject);
         IEnumerable<ObjectClass1> Objects = TestObject.All();
         Assert.Equal(1, Objects.Count());
         foreach (ObjectClass1 Item in Objects)
         {
             Assert.Equal("Test String", Item.StringValue);
             Assert.Equal(1234.5f, Item.FloatValue);
             Assert.Equal(true, Item.BoolValue);
             Assert.Equal(12345, Item.LongValue);
             Assert.Equal(1, Item.ID);
             Assert.Equal(TempObject.StringMaxValue, Item.StringMaxValue);
         }
         List<ObjectClass1> Objects2 = new List<ObjectClass1>();
         Rand = new Utilities.Random.Random();
         for (int x = 0; x < 10; ++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(0, 100);
             TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
             Objects2.Add(TempObject);
         }
         TestObject.Save<int>(Objects2);
         Objects = TestObject.All();
         Assert.Equal(11, Objects.Count());
     }
 }
Example #8
0
        public void Paged2()
        {
            using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
            {
                TestObject.Map(x => x.ID, "ID_")
                .Map(x => x.StringValue, "StringValue_", 100)
                .Map(x => x.FloatValue, "FloatValue_")
                .Map(x => x.BoolValue, "BoolValue_")
                .Map(x => x.LongValue, "LongValue_")
                .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
                List <ObjectClass1>     Objects2 = new List <ObjectClass1>();
                Utilities.Random.Random Rand     = new Utilities.Random.Random();
                for (int x = 0; x < 115; ++x)
                {
                    ObjectClass1 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(0, 100);
                    TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
                    Objects2.Add(TempObject);
                }
                TestObject.Save <int>(Objects2);
                IEnumerable <ObjectClass1> Objects = TestObject.PagedCommand("SELECT * FROM TestTable");
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 1);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 2);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 3);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 4);
                Assert.Equal(15, Objects.Count());
                Assert.Equal(5, TestObject.PageCount("SELECT * FROM TestTable"));

                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 0, null, null, new EqualParameter <int>(50, "ID"));
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 1, null, null, new EqualParameter <int>(50, "ID"));
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 2, null, null, new EqualParameter <int>(50, "ID"));
                Assert.Equal(15, Objects.Count());
                Assert.Equal(3, TestObject.PageCount("SELECT * FROM TestTable WHERE ID_>@ID", 25, new EqualParameter <int>(50, "ID")));
            }
        }
Example #9
0
 public void Any()
 {
     using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_", 100)
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_");
         ObjectClass1 TempObject = new ObjectClass1();
         TempObject.StringValue = "Test String";
         TempObject.BoolValue   = true;
         TempObject.FloatValue  = 1234.5f;
         TempObject.LongValue   = 12345;
         TestObject.Save <int>(TempObject);
         TempObject = TestObject.Any();
         Assert.Equal("Test String", TempObject.StringValue);
         Assert.Equal(1234.5f, TempObject.FloatValue);
         Assert.Equal(true, TempObject.BoolValue);
         Assert.Equal(12345, TempObject.LongValue);
         Assert.Equal(1, TempObject.ID);
     }
 }
 public void Scalar()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_")
             .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand = new Utilities.Random.Random(12345);
         for (int x = 0; x < 100; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue = "Test String";
             TempObject.BoolValue = true;
             TempObject.FloatValue = 1234.5f;
             TempObject.LongValue = 12345;
             TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
             string StringMaxValue = TempObject.StringMaxValue;
             TestObject.Save<int>(TempObject);
         }
         int ASD = TestObject.Scalar<int>("SELECT COUNT(*) FROM TestTable", CommandType.Text);
         Assert.Equal(100, ASD);
         ASD = TestObject.Scalar<int>("COUNT(*)");
         Assert.Equal(100, ASD);
     }
 }
 public void Save()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_")
             .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand = new Utilities.Random.Random(12346);
         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));
         TestObject.Save<int>(TempObject);
         Rand = new Utilities.Random.Random(12345);
         TempObject.StringValue = "Test String";
         TempObject.BoolValue = true;
         TempObject.FloatValue = 1234.5f;
         TempObject.LongValue = 12345;
         TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
         TestObject.Save<int>(TempObject);
         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>("StringValue_", ""));
                 Assert.Equal(1234.5f, Helper.GetParameter<float>("FloatValue_", 0));
                 Assert.Equal(true, Helper.GetParameter<bool>("BoolValue_", false));
                 Assert.Equal(12345, Helper.GetParameter<long>("LongValue_", 0));
                 Assert.Equal(TempObject.ID, Helper.GetParameter<int>("ID_", 0));
                 Assert.Equal(TempObject.StringMaxValue, Helper.GetParameter<string>("StringMaxValue_", ""));
             }
             else
             {
                 Assert.Fail("Nothing was inserted");
             }
         }
     }
 }
        public void Paged2()
        {
            using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
            {
                TestObject.Map(x => x.ID, "ID_")
                    .Map(x => x.StringValue, "StringValue_", 100)
                    .Map(x => x.FloatValue, "FloatValue_")
                    .Map(x => x.BoolValue, "BoolValue_")
                    .Map(x => x.LongValue, "LongValue_")
                    .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
                List<ObjectClass1> Objects2 = new List<ObjectClass1>();
                Utilities.Random.Random Rand = new Utilities.Random.Random();
                for (int x = 0; x < 115; ++x)
                {
                    ObjectClass1 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(0, 100);
                    TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
                    Objects2.Add(TempObject);
                }
                TestObject.Save<int>(Objects2);
                IEnumerable<ObjectClass1> Objects = TestObject.PagedCommand("SELECT * FROM TestTable");
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 1);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 2);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 3);
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable", CurrentPage: 4);
                Assert.Equal(15, Objects.Count());
                Assert.Equal(5, TestObject.PageCount("SELECT * FROM TestTable"));

                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 0, null, null, new EqualParameter<int>(50, "ID"));
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 1, null, null, new EqualParameter<int>(50, "ID"));
                Assert.Equal(25, Objects.Count());
                Objects = TestObject.PagedCommand("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 2, null, null, new EqualParameter<int>(50, "ID"));
                Assert.Equal(15, Objects.Count());
                Assert.Equal(3, TestObject.PageCount("SELECT * FROM TestTable WHERE ID_>@ID", 25, new EqualParameter<int>(50, "ID")));
            }
        }
 public void Any()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_")
             .Map(x => x.StringMaxValue, "StringMaxValue_", -1);
         Utilities.Random.Random Rand = new Utilities.Random.Random(12345);
         ObjectClass1 TempObject = new ObjectClass1();
         TempObject.StringValue = "Test String";
         TempObject.BoolValue = true;
         TempObject.FloatValue = 1234.5f;
         TempObject.LongValue = 12345;
         TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
         string StringMaxValue = TempObject.StringMaxValue;
         TestObject.Save<int>(TempObject);
         TempObject = TestObject.Any();
         Assert.Equal("Test String", TempObject.StringValue);
         Assert.Equal(1234.5f, TempObject.FloatValue);
         Assert.Equal(true, TempObject.BoolValue);
         Assert.Equal(12345, TempObject.LongValue);
         Assert.Equal(1, TempObject.ID);
         Assert.Equal(StringMaxValue, TempObject.StringMaxValue);
     }
 }
Example #14
0
 public void Paged()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_");
         List<ObjectClass1> Objects2 = new List<ObjectClass1>();
         Utilities.Random.Random Rand = new Utilities.Random.Random();
         for (int x = 0; x < 115; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue = Rand.NextString(10);
             TempObject.BoolValue = Rand.NextBool();
             TempObject.FloatValue = (float)Rand.NextDouble();
             TempObject.LongValue = Rand.Next(0, 100);
             Objects2.Add(TempObject);
         }
         TestObject.Save<int>(Objects2);
         IEnumerable<ObjectClass1> Objects = TestObject.Paged();
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage:1);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 2);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 3);
         Assert.Equal(25, Objects.Count());
         Objects = TestObject.Paged(CurrentPage: 4);
         Assert.Equal(15, Objects.Count());
         Assert.Equal(5, TestObject.PageCount());
     }
 }
Example #15
0
        public void Delete()
        {
            using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
            {
                TestObject.Map(x => x.ID, "ID_")
                    .Map(x => x.StringValue, "StringValue_", 100)
                    .Map(x => x.FloatValue, "FloatValue_")
                    .Map(x => x.BoolValue, "BoolValue_")
                    .Map(x => x.LongValue, "LongValue_");
                ObjectClass1 TempObject = new ObjectClass1();
                TempObject.StringValue = "Test";
                TempObject.BoolValue = false;
                TempObject.FloatValue = 1.5f;
                TempObject.LongValue = 12;
                TestObject.Save<int>(TempObject);
                Assert.Equal(1, TestObject.Delete(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.Fail("Nothing was inserted");
                    }
                }
            }
        }
Example #16
0
 public void Any()
 {
     using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_"))
     {
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_", 100)
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_");
         ObjectClass1 TempObject = new ObjectClass1();
         TempObject.StringValue = "Test String";
         TempObject.BoolValue = true;
         TempObject.FloatValue = 1234.5f;
         TempObject.LongValue = 12345;
         TestObject.Save<int>(TempObject);
         TempObject = TestObject.Any();
         Assert.Equal("Test String", TempObject.StringValue);
         Assert.Equal(1234.5f, TempObject.FloatValue);
         Assert.Equal(true, TempObject.BoolValue);
         Assert.Equal(12345, TempObject.LongValue);
         Assert.Equal(1, TempObject.ID);
     }
 }