コード例 #1
0
 public async void SimpleInsertTest(IRunner runner)
 {
     var inp = new SomeEntity {
         AnInt   = 5,
         AString = "foo"
     };
     await runner.Run(_logger, async db => {
         await db.InsertAsync(inp);
         Assert.Equal(1, await db.ExecuteScalarAsync <int>("select count(*) from SomeEntity"));
         Assert.NotEqual(0, inp.Id);
     });
 }
コード例 #2
0
        public async void SimpleNotExistsTest(IRunner runner)
        {
            var inp = new SomeEntity {
                AnInt   = 5,
                AString = "foo1"
            };

            await runner.Run(_logger, async db => {
                await db.InsertAsync(inp);

                Assert.False(await db.ExistsAsync <SomeEntity>(x => x.AString == "foo"));
            });
        }
コード例 #3
0
        public async void IsNullSingleTest(IRunner runner)
        {
            var inp = new SomeEntity {
                AnInt   = 5,
                AString = "foo"
            };

            await runner.Run(_logger, async db => {
                await db.InsertAsync(inp);

                var outp = await db.SingleAsync <SomeEntity>(x => x.NullableInt == null);
                Assert.Equal(inp, outp);
            });
        }
コード例 #4
0
        public async void SimpleFetchTest(IRunner runner)
        {
            var inp = new SomeEntity {
                AnInt   = 5,
                AString = "foo"
            };

            await runner.Run(_logger, async db => {
                await db.InsertAsync(inp);

                var outp = await db.FetchAsync <SomeEntity>(x => x.AString == "foo");
                Assert.Equal(new List <SomeEntity> {
                    inp
                }, outp);
            });
        }
コード例 #5
0
        public async void ColumnNameInAttribute(IRunner runner)
        {
            var inp = new SomeEntity {
                OfficialName = "foo"
            };

            await runner.Run(_logger, async db => {
                await db.InsertAsync(inp);

                //note actualName iso OfficialName
                var outp1 = (await db.FetchAsync <SomeEntity>("select Id,AnInt,AString,NullableInt,actualName from SomeEntity")).Single();
                Assert.Equal(inp, outp1);

                var outp2 = await db.SingleAsync <SomeEntity>(x => x.OfficialName == "foo");
                Assert.Equal(inp, outp2);
            });
        }
コード例 #6
0
        public async void SimpleDeleteTest(IRunner runner)
        {
            var inp1 = new SomeEntity {
                AnInt   = 5,
                AString = "foo1"
            };

            var inp2 = new SomeEntity {
                AnInt   = 5,
                AString = "foo2"
            };

            await runner.Run(_logger, async db => {
                await db.InsertAsync(inp1);
                await db.InsertAsync(inp2);

                var outp = await db.DeleteAsync <SomeEntity>(x => x.AString == "foo1");
                Assert.Equal(1, outp);
                Assert.Equal(inp2, await db.SingleAsync <SomeEntity>(x => x.AnInt == 5));
            });
        }