Example #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);
     });
 }
Example #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"));
            });
        }
Example #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);
            });
        }
Example #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);
            });
        }
Example #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);
            });
        }
Example #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));
            });
        }