public async Task RawScalatQueryAsync()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            context.Skills.Insert(new SqlServerSkill
            {
                PersonId = person.Id,
                Title    = "HTML/CSS"
            });
            context.Skills.Insert(new SqlServerSkill
            {
                PersonId = person.Id,
                Title    = "JavaScript"
            });
            var skillsCount = await context.RawScalarQueryAsync <int>("SELECT COUNT(*) FROM [Skills] WHERE [Skills].[PersonId] = @personId", new { personId = person.Id });

            Assert.Equal(2, skillsCount);
        }
        public async Task RawQueryAsync()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            await context.Persons.InsertAsync(person);

            await context.Skills.InsertAsync(new SqlServerSkill
            {
                PersonId = person.Id,
                Title    = "HTML/CSS"
            });

            await context.Skills.InsertAsync(new SqlServerSkill
            {
                PersonId = person.Id,
                Title    = "JavaScript"
            });

            var personsSkills = await context.RawQueryAsync <SqlServerPersonSkill>(@"SELECT [Persons].[Name] + ' ' + [Persons].[Family] AS FullName, 
                                                                                         [Skills].[Title] AS Skill
                                                                                  FROM [Persons] JOIN [Skills] 
                                                                                  ON [Persons].[Id] = [Skills].[PersonId];");

            Assert.True(personsSkills.Count() > 0);
        }
        public void Insert()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            Assert.True(person.Id > 0);
        }
        public void Where()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            var findPerson = context.Persons.Where("Id = @id", new { id = person.Id });

            Assert.NotNull(findPerson);
        }
        public void RawNonQuery()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            context.RawNonQuery("UPDATE [Persons] SET [Name] = @name WHERE Id = @id", new { name = "mh", id = person.Id });
            var findPerson = context.Persons.Find(person.Id);

            Assert.Equal("mh", findPerson.Name);
        }
        public async Task Find()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            await context.Persons.InsertAsync(person);

            var findPerson = await context.Persons.FindAsync(person.Id);

            Assert.NotNull(findPerson);
        }
        public void Update()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            person.Age = 42;
            context.Persons.Update(person);
            var changedPerson = context.Persons.Find(person.Id);

            Assert.Equal(42, changedPerson.Age);
        }
        public void Delete()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            context.Persons.Insert(person);
            var findPerson = context.Persons.Find(person.Id);

            Assert.NotNull(person);
            context.Persons.Delete(person.Id);
            var deletePerson = context.Persons.Find(person.Id);

            Assert.Null(deletePerson);
        }
        public void Transaction_RollBack()
        {
            var person = new SqlServerPerson
            {
                Name   = "MohammadHasan",
                Family = "Farzin",
                Age    = 32,
                Gender = SqlServerGender.Male
            };

            using var context = ContextFactory.GetSqlServerContext();
            context.DataBaseTruncate();
            using (var transaction = context.BeginTransaction())
            {
                context.Persons.Insert(person, transaction);
                transaction.RollBack();
            }
            var persons = context.Persons.All();

            Assert.Empty(persons);
        }