Esempio n. 1
0
 public void All()
 {
     Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     Utilities.SQL.MicroORM.MicroORM.Map<ObjectClass1>("TestTable", "ID_")
             .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 = null;
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM())
     {
         for (int x = 0; x < 100; ++x)
         {
             TempObject = new ObjectClass1();
             TempObject.StringValue = Rand.NextString(10);
             TempObject.BoolValue = Rand.NextBool();
             TempObject.FloatValue = (float)Rand.NextDouble();
             TempObject.LongValue =Rand.Next();
             ORM.Map<ObjectClass1>().Save<int>(TempObject);
         }
         TempObject = null;
         IEnumerable<ObjectClass1> Objects = ORM.Map<ObjectClass1>().All();
         Assert.Equal(100, Objects.Count());
     }
 }
Esempio n. 2
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());
     }
 }
        public void Delete()
        {
            Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
            Utilities.SQL.MicroORM.MicroORM.Map <ObjectClass1>("TestTable", "ID_")
            .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 = null;

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM())
            {
                for (int x = 0; x < 100; ++x)
                {
                    TempObject             = new ObjectClass1();
                    TempObject.StringValue = Rand.NextString(10);
                    TempObject.BoolValue   = Rand.NextBool();
                    TempObject.FloatValue  = (float)Rand.NextDouble();
                    TempObject.LongValue   = Rand.Next();
                    ORM.Map <ObjectClass1>().Save <int>(TempObject);
                }
                TempObject = null;
                IEnumerable <ObjectClass1> Objects = ORM.Map <ObjectClass1>().All();
                Assert.Equal(100, Objects.Count());
                foreach (ObjectClass1 Object in Objects)
                {
                    ORM.Map <ObjectClass1>().Delete(Object);
                }
                Objects = ORM.Map <ObjectClass1>().All();
                Assert.Equal(0, Objects.Count());
            }
        }
 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.NextString(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.NextString(10);
             TempObject.BoolValue      = Rand.NextBool();
             TempObject.FloatValue     = (float)Rand.NextDouble();
             TempObject.LongValue      = Rand.Next(0, 100);
             TempObject.StringMaxValue = Rand.NextString(6000);
             Objects2.Add(TempObject);
         }
         TestObject.Save <int>(Objects2);
         Objects = TestObject.All();
         Assert.Equal(11, Objects.Count());
     }
 }
Esempio n. 5
0
 public void NextBoolTest()
 {
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     Assert.DoesNotThrow<Exception>(() => Rand.NextBool());
 }
Esempio n. 6
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_");
         ObjectClass1 TempObject = new ObjectClass1();
         TempObject.StringValue = "Test String";
         TempObject.BoolValue = true;
         TempObject.FloatValue = 1234.5f;
         TempObject.LongValue = 12345;
         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);
         }
         List<ObjectClass1> Objects2 = new List<ObjectClass1>();
         Utilities.Random.Random Rand = new Utilities.Random.Random();
         for (int x = 0; x < 10; ++x)
         {
             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);
         Objects = TestObject.All();
         Assert.Equal(11, Objects.Count());
     }
 }
Esempio n. 7
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());
     }
 }
Esempio n. 8
0
 public void NextBoolTest()
 {
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     Assert.DoesNotThrow <Exception>(() => Rand.NextBool());
 }