当前位置: 首页>>代码示例>>C#>>正文


C# Tests.TestDb类代码示例

本文整理汇总了C#中SQLite.Net.Tests.TestDb的典型用法代码示例。如果您正苦于以下问题:C# TestDb类的具体用法?C# TestDb怎么用?C# TestDb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestDb类属于SQLite.Net.Tests命名空间,在下文中一共展示了TestDb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public void Setup()
        {
            testObjects = Enumerable.Range(1, 20).Select(i => new TestObj()).ToList();

            db = new TestDb(TestPath.CreateTemporaryDatabase());
            db.InsertAll(testObjects);
        }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:7,代码来源:TransactionTest.cs

示例2: CreateDb

        private SQLiteConnection CreateDb()
        {
            var db = new TestDb();

            db.CreateTable<TestTable>();
            db.CreateTable<TestTableCompositeKey>();

            var items =
                from i in Enumerable.Range(0, Count)
                select new TestTable
                {
                    Datum = 1000 + i,
                    Test = "Hello World"
                }
                ;
            db.InsertAll(items);

            var itemsCompositeKey =
                from i in Enumerable.Range(0, Count)
                select new TestTableCompositeKey
                {
                    Datum = 1000 + i,
                    Test = "Hello World",
                    Id = i,
                    TestIndex = i + 1
                }
                ;
            db.InsertAll(itemsCompositeKey);
            Assert.AreEqual(Count, db.Table<TestTableCompositeKey>().Count());

            return db;
        }
开发者ID:Rhapsody,项目名称:SQLite.Net-PCL,代码行数:32,代码来源:DeleteTest.cs

示例3: ContainsQueriedData

        public void ContainsQueriedData()
        {
            int n = 20;
            IEnumerable<TestObj> cq = from i in Enumerable.Range(1, n)
                select new TestObj
                {
                    Name = i.ToString()
                };

            var db = new TestDb(new SQLitePlatformWin32(), TestPath.GetTempFileName());

            db.InsertAll(cq);

            db.Trace = true;

            var tensq = new[] {"0", "10", "20"};
            List<TestObj> tens = (from o in db.Table<TestObj>() where tensq.Contains(o.Name) select o).ToList();
            Assert.AreEqual(2, tens.Count);

            var moreq = new[] {"0", "x", "99", "10", "20", "234324"};
            List<TestObj> more = (from o in db.Table<TestObj>() where moreq.Contains(o.Name) select o).ToList();
            Assert.AreEqual(2, more.Count);

            // https://github.com/praeclarum/SQLite.Net/issues/28
            List<string> moreq2 = moreq.ToList();
            List<TestObj> more2 = (from o in db.Table<TestObj>() where moreq2.Contains(o.Name) select o).ToList();
            Assert.AreEqual(2, more2.Count);
        }
开发者ID:giacatlaoboi,项目名称:SQLite.Net-PCL,代码行数:28,代码来源:ContainsTest.cs

示例4: Skip

        public void Skip()
        {
            int n = 100;

            IEnumerable<TestObj> cq = from i in Enumerable.Range(1, n)
                select new TestObj
                {
                    Order = i
                };
            TestObj[] objs = cq.ToArray();
            var db = new TestDb(TestPath.GetTempFileName());

            int numIn = db.InsertAll(objs);
            Assert.AreEqual(numIn, n, "Num inserted must = num objects");

            TableQuery<TestObj> q = from o in db.Table<TestObj>()
                orderby o.Order
                select o;

            TableQuery<TestObj> qs1 = q.Skip(1);
            List<TestObj> s1 = qs1.ToList();
            Assert.AreEqual(n - 1, s1.Count);
            Assert.AreEqual(2, s1[0].Order);

            TableQuery<TestObj> qs5 = q.Skip(5);
            List<TestObj> s5 = qs5.ToList();
            Assert.AreEqual(n - 5, s5.Count);
            Assert.AreEqual(6, s5[0].Order);
        }
开发者ID:flowpilots,项目名称:SQLite.Net-PCL,代码行数:29,代码来源:SkipTest.cs

示例5: TestColumnValues

        public void TestColumnValues()
        {
            using (TestDb db = new TestDb())
            {
                db.CreateTable<WithDefaultValue>();
               

                string failed = string.Empty;
                foreach (var col in db.GetMapping<WithDefaultValue>().Columns)
                {
                    if (col.PropertyName == "TestInt" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
                        failed += " , TestInt does not equal " + WithDefaultValue.IntVal;

                    if (col.PropertyName == "TestDecimal" && !col.DefaultValue.Equals(WithDefaultValue.DecimalVal))
                        failed += "TestDecimal does not equal " + WithDefaultValue.DecimalVal;

                    if (col.PropertyName == "TestDateTime" && !col.DefaultValue.Equals(WithDefaultValue.DateTimegVal))
                        failed += "TestDateTime does not equal " + WithDefaultValue.DateTimegVal;

                    if (col.PropertyName == "TestString" && !col.DefaultValue.Equals(WithDefaultValue.StringVal))
                        failed += "TestString does not equal " + WithDefaultValue.StringVal;
                }
                
                Assert.True(string.IsNullOrWhiteSpace(failed), failed);

            }
        }
开发者ID:quentez,项目名称:SQLite.Net-PCL,代码行数:27,代码来源:DefaulAttributeTest.cs

示例6: Setup

        public void Setup()
        {
            testObjects = Enumerable.Range(1, 20).Select(i => new TestObj()).ToList();

            db = new TestDb(TestPath.GetTempFileName());
            db.InsertAll(testObjects);
        }
开发者ID:flowpilots,项目名称:SQLite.Net-PCL,代码行数:7,代码来源:TransactionTest.cs

示例7: Collate

        public void Collate()
        {
            var obj = new TestObj
            {
                CollateDefault = "Alpha ",
                CollateBinary = "Alpha ",
                CollateRTrim = "Alpha ",
                CollateNoCase = "Alpha ",
            };

            var db = new TestDb(new SQLitePlatformTest(), TestPath.GetTempFileName());

            db.Insert(obj);

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA " select o).Count());
            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha " select o).Count());
            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA" select o).Count());
        }
开发者ID:jdasilva,项目名称:SQLite.Net-PCL,代码行数:34,代码来源:CollateTest.cs

示例8: CreateDb

 private TestDb CreateDb()
 {
     var db = new TestDb();
     db.CreateTable<Product>();
     db.CreateTable<Order>();
     db.CreateTable<OrderLine>();
     db.CreateTable<OrderHistory>();
     return db;
 }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:9,代码来源:LinqTest.cs

示例9: InheritanceWorks

        public void InheritanceWorks()
        {
            var db = new TestDb();

            TableMapping mapping = db.GetMapping<Derived>();

            Assert.AreEqual(3, mapping.Columns.Length);
            Assert.AreEqual("Id", mapping.PK.Name);
        }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:9,代码来源:InheritanceTest.cs

示例10: CreateAsPassedInTypes

        public void CreateAsPassedInTypes()
        {
            var db = new TestDb();

            db.CreateTable(typeof (Product));
            db.CreateTable(typeof (Order));
            db.CreateTable(typeof (OrderLine));
            db.CreateTable(typeof (OrderHistory));

            VerifyCreations(db);
        }
开发者ID:flowpilots,项目名称:SQLite.Net-PCL,代码行数:11,代码来源:CreateTableTest.cs

示例11: CreateThem

        public void CreateThem()
        {
            var db = new TestDb();

            db.CreateTable<Product>();
            db.CreateTable<Order>();
            db.CreateTable<OrderLine>();
            db.CreateTable<OrderHistory>();

            VerifyCreations(db);
        }
开发者ID:flowpilots,项目名称:SQLite.Net-PCL,代码行数:11,代码来源:CreateTableTest.cs

示例12: ImplicitIndex

        public void ImplicitIndex()
        {
            var db = new TestDb();

            db.CreateTable<NoAttributes>(CreateFlags.ImplicitIndex);

            TableMapping mapping = db.GetMapping<NoAttributes>();
            TableMapping.Column column = mapping.Columns[2];
            Assert.AreEqual("IndexedId", column.Name);
            Assert.IsTrue(column.Indices.Any());
        }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:11,代码来源:CreateTableImplicitTest.cs

示例13: SetUp

        public void SetUp()
        {
            _db = new TestDb();
            _db.CreateTable<Product>();
            _db.CreateTable<Order>();
            _db.CreateTable<OrderLine>();

            var p1 = new Product
            {
                Name = "One",
            };
            var p2 = new Product
            {
                Name = "Two",
            };
            var p3 = new Product
            {
                Name = "Three",
            };
            _db.InsertAll(new[] {p1, p2, p3});

            var o1 = new Order
            {
                PlacedTime = DateTime.Now,
            };
            var o2 = new Order
            {
                PlacedTime = DateTime.Now,
            };
            _db.InsertAll(new[] {o1, o2});

            _db.InsertAll(new[]
            {
                new OrderLine
                {
                    OrderId = o1.Id,
                    ProductId = p1.Id,
                    Quantity = 1,
                },
                new OrderLine
                {
                    OrderId = o1.Id,
                    ProductId = p2.Id,
                    Quantity = 2,
                },
                new OrderLine
                {
                    OrderId = o2.Id,
                    ProductId = p3.Id,
                    Quantity = 3,
                }
            });
        }
开发者ID:flowpilots,项目名称:SQLite.Net-PCL,代码行数:53,代码来源:JoinTest.cs

示例14: TestAsyncDateTime

        private async Task TestAsyncDateTime(SQLiteAsyncConnection db)
        {
            await db.CreateTableAsync<TestDb>();

            var val1 = new TestDb
            {
                Time = new TimeSpan(1000),
            };
            await db.InsertAsync(val1);
            TestDb val2 = await db.GetAsync<TestDb>(val1.Id);
            Assert.AreEqual(val1.Time, val2.Time);
        }
开发者ID:NateRickard,项目名称:SQLite.Net-PCL,代码行数:12,代码来源:TimeSpanTest.cs

示例15: ImplicitAutoIncAsPassedInTypes

        public void ImplicitAutoIncAsPassedInTypes()
        {
            var db = new TestDb();

            db.CreateTable(typeof (PkAttribute), CreateFlags.AutoIncPK);

            TableMapping mapping = db.GetMapping<PkAttribute>();

            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsTrue(mapping.PK.IsAutoInc);
        }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:13,代码来源:CreateTableImplicitTest.cs


注:本文中的SQLite.Net.Tests.TestDb类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。