Ejemplo n.º 1
0
        public void Insert_value_success()
        {
            var query  = Prepare.SqlQuery();
            var result = query.Execute("insert into author (name, description) values (@name, @description)", SqlHelper.Parameters.Get("@name", "Isaac"), SqlHelper.Parameters.Get("@description", "sci-fi"));

            Assert.True(result);
        }
Ejemplo n.º 2
0
        public void Create_success()
        {
            var query  = Prepare.SchemaQuery();
            var result = query.CreateSchema();

            Assert.True(result);
        }
Ejemplo n.º 3
0
        public void Alter_success()
        {
            var query  = Prepare.SchemaQuery();
            var result = query.UpdateSchema();

            Assert.True(result);
        }
Ejemplo n.º 4
0
        public void Drop_success()
        {
            var query  = Prepare.SchemaQuery();
            var result = query.DeleteSchema();

            Assert.True(result);
        }
Ejemplo n.º 5
0
        public void Update_all_one_success()
        {
            var query = Prepare.SetQuery();

            var allProperty = Prepare.GetQuery().GetFirst(a => a.Id == 7);

            allProperty.index       = DateTime.Now.Day;
            allProperty.description = $"Updated on {DateTime.Now}";
            allProperty.datemod     = DateTime.Now;
            allProperty.amount      = DateTime.Now.DayOfYear;

            var result = query.Update(allProperty);

            Assert.True(result);

            var oneProperty = Prepare.GetQuery().GetFirst(a => a.Id == 9);

            oneProperty.index       = DateTime.Now.Day;
            oneProperty.description = $"Updated on {DateTime.Now}";
            oneProperty.datemod     = DateTime.Now;
            oneProperty.amount      = DateTime.Now.DayOfYear;

            result = query.Update(oneProperty, p => p.description);

            Assert.True(result);
        }
Ejemplo n.º 6
0
        public void GetFirst_not_null_value_match()
        {
            var query  = Prepare.SqlQuery();
            var result = query.GetFirst <AuthorObj>("select Id, name from author where Id > 5");

            Assert.NotNull(result);
            Assert.Equal(6, result.Id);
        }
Ejemplo n.º 7
0
        public void GetList_not_null_count()
        {
            var query  = Prepare.SqlQuery();
            var result = query.GetList <AuthorObj>("select Id, name from author where Id >= 3 and Id <= 12");

            Assert.NotNull(result);
            Assert.Equal(10, result.Count);
        }
Ejemplo n.º 8
0
        public void Insert_Delete_success()
        {
            var query  = Prepare.SetQuery();
            var result = query.Insert(new Author {
                index = 99, Name = "New insert", amount = 88, datemod = DateTime.Now
            });

            Assert.True(result);

            result = query.Delete(a => a.index == 99);
            Assert.True(result);
        }
Ejemplo n.º 9
0
        public void GetFirst_not_null_value_match_dto()
        {
            var query  = Prepare.GetQuery();
            var result = query.GetFirst(a => a.Id > 2);
            var dto    = query.GetFirst(a => a.Id > 2, s => new AuthorDto {
                Id = s.Id, name = s.Name
            });

            Assert.NotNull(result);
            Assert.Equal(3, result.Id);

            Assert.NotNull(dto);
            Assert.Equal(3, dto.Id);
        }
Ejemplo n.º 10
0
        public void GetBottom_not_null_value_match_dto()
        {
            var query  = Prepare.GetQuery();
            var result = query.GetBottom(a => a.Id >= 5, k => k.Id);
            var dto    = query.GetBottom(a => a.Id >= 5, k => k.Id, s => new AuthorDto {
                Id = s.Id, name = s.Name
            });

            Assert.NotNull(result);
            Assert.Equal(5, result.Id);

            Assert.NotNull(dto);
            Assert.Equal(5, dto.Id);
        }
Ejemplo n.º 11
0
        public void GetOrderedList_not_null_count_dto()
        {
            var query  = Prepare.GetQuery();
            var all    = query.GetOrderedList(k => k.Name);
            var notall = query.GetOrderedList(k => k.Name, a => a.index > 0 && a.index <= 11);
            var dto    = query.GetOrderedList(k => k.Name, s => new AuthorDto {
                Id = s.Id, name = s.Name
            }, a => a.index > 0 && a.index <= 11);

            Assert.NotNull(all);
            Assert.True(all.Count > 10);

            Assert.NotNull(notall);
            Assert.Equal(6, notall.Count);

            Assert.NotNull(dto);
            Assert.Equal(6, dto.Count);
        }
Ejemplo n.º 12
0
        public void GetRangeOrderBy_not_null_count_dto()
        {
            var query  = Prepare.GetQuery();
            var all    = query.GetRangeOrderBy((0, 3), k => k.Id);
            var notall = query.GetRangeOrderBy((2, 3), k => k.Id, a => a.index > 0 && a.index <= 11);
            var dto    = query.GetRangeOrderBy((2, 3), k => k.Id, s => new AuthorDto {
                Id = s.Id, name = s.Name
            }, a => a.index > 0 && a.index <= 11);

            Assert.NotNull(all);
            Assert.Equal(3, all.Count);

            Assert.NotNull(notall);
            Assert.Equal(3, notall.Count);

            Assert.NotNull(dto);
            Assert.Equal(3, dto.Count);
        }
Ejemplo n.º 13
0
        public void InsertBulk_success()
        {
            var query   = Prepare.SetQuery();
            var newList = new List <Author> {
                new Author {
                    index       = DateTime.Now.Day,
                    description = $"Inserted (1) on {DateTime.Now}",
                    datemod     = DateTime.Now,
                    amount      = DateTime.Now.DayOfYear
                },
                new Author {
                    index       = DateTime.Now.Day,
                    description = $"Inserted (2) on {DateTime.Now}",
                    datemod     = DateTime.Now,
                    amount      = DateTime.Now.DayOfYear
                }
            };
            var result = query.InsertBulk(newList);

            Assert.True(result);
        }