public async Task DataFlow_HardDeleteById_Test()
        {
            IPostsRepository postsRepository = new PostsRepository();

            IoCManager.Resolver.InjectProperties(postsRepository);

            var findAllResult = await postsRepository.FindAll();

            Assert.IsEmpty(findAllResult);

            var postCount  = 0;
            var savedPosts = await postsRepository.SaveAll(
                new[]
            {
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
            });

            Assert.IsNotNull(savedPosts);
            Assert.IsNotEmpty(savedPosts);
            Assert.AreEqual(postCount, savedPosts.Count);

            foreach (var postEntity in savedPosts)
            {
                Assert.IsFalse(postEntity.IsDeleted);
            }

            var secondPost = savedPosts[1];

            await postsRepository.DeleteById(secondPost.PostId, softDelete : false);

            var foundPosts = await postsRepository.FindAll();

            Assert.IsNotNull(foundPosts);
            Assert.IsNotEmpty(foundPosts);
            Assert.AreEqual(postCount - 1, foundPosts.Count);

            foreach (var postEntity in foundPosts)
            {
                Assert.IsFalse(postEntity.IsDeleted);
            }
        }
        public async Task DataFlow_InsertPostEntity_Test()
        {
            IPostsRepository postsRepository = new PostsRepository();

            IoCManager.Resolver.InjectProperties(postsRepository);

            var findAllResult = await postsRepository.FindAll();

            Assert.IsEmpty(findAllResult);

            var samplePost1 = new PostEntity
            {
                Title = Post1Title1, Content = Post1Content1
            };

            Assert.AreEqual(0, samplePost1.PostId);

            samplePost1 = await postsRepository.Save(samplePost1);

            Assert.AreNotEqual(0, samplePost1.PostId);

            findAllResult = await postsRepository.FindAll();

            Assert.IsNotEmpty(findAllResult);
            Assert.AreEqual(1, findAllResult.Count);

            var postFound = await postsRepository.FindById(1);

            Assert.IsNotNull(postFound);
            Assert.IsNotNull(postFound.PostId);
            Assert.AreEqual(1, postFound.PostId);
            Assert.AreEqual(Post1Title1, postFound.Title);
            Assert.AreEqual(Post1Content1, postFound.Content);

            Assert.ThrowsAsync <GrException>(() => postsRepository.FindById(1000));
        }
        public async Task DataFlow_FindPageAndMap_Test()
        {
            IPostsRepository postsRepository = new PostsRepository();

            IoCManager.Resolver.InjectProperties(postsRepository);

            var findAllResult = await postsRepository.FindAll();

            Assert.IsEmpty(findAllResult);

            var postCount  = 0;
            var savedPosts = await postsRepository.SaveAll(
                new[]
            {
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
                new PostEntity {
                    Title = $"{postCount}", Content = $"{postCount++}"
                },
            });

            Assert.IsNotNull(savedPosts);
            Assert.IsNotEmpty(savedPosts);
            Assert.AreEqual(postCount, savedPosts.Count);

            var foundPage = await postsRepository.FindAll(Pageable.Of(1, 2));

            Assert.IsNotNull(foundPage);
            Assert.IsNotNull(foundPage.PageInfo);
            Assert.AreEqual(postCount, foundPage.Total);

            Assert.IsNotNull(foundPage.Content);
            Assert.AreEqual(2, foundPage.Content.Count);

            Assert.IsNotNull(foundPage.Content[0]);
            Assert.AreEqual("2", foundPage.Content[0].Title);

            Assert.IsNotNull(foundPage.Content[1]);
            Assert.AreEqual("3", foundPage.Content[1].Title);


            var mappedPage = foundPage.Map(entity => entity.Title);

            Assert.IsNotNull(mappedPage);
            Assert.IsNotNull(mappedPage.PageInfo);
            Assert.AreEqual(postCount, mappedPage.Total);

            Assert.IsNotNull(mappedPage.Content);
            Assert.AreEqual(2, mappedPage.Content.Count);
            Assert.AreEqual("2", mappedPage.Content[0]);
            Assert.AreEqual("3", mappedPage.Content[1]);
        }
        public async Task DataFlow_InsertUpdatePost_Test()
        {
            IPostsRepository postsRepository = new PostsRepository();

            IoCManager.Resolver.InjectProperties(postsRepository);

            var findAllResult = await postsRepository.FindAll();

            Assert.IsEmpty(findAllResult);

            var samplePost1 = new PostEntity
            {
                Title = Post1Title1, Content = Post1Content1
            };
            var samplePost2 = new PostEntity
            {
                Title = Post2Title1, Content = Post2Content1
            };

            var savedPosts = await postsRepository.SaveAll(
                new[] { samplePost1, samplePost2 });

            Assert.IsNotNull(savedPosts);
            Assert.IsNotEmpty(savedPosts);
            Assert.AreEqual(2, savedPosts.Count);

            samplePost1 = savedPosts[0];
            samplePost2 = savedPosts[1];

            Assert.AreNotEqual(0, samplePost1.PostId);
            Assert.AreEqual(1, samplePost1.PostId);
            Assert.AreEqual(Post1Title1, samplePost1.Title);
            Assert.AreEqual(Post1Content1, samplePost1.Content);

            Assert.AreNotEqual(0, samplePost2.PostId);
            Assert.AreEqual(2, samplePost2.PostId);
            Assert.AreEqual(Post2Title1, samplePost2.Title);
            Assert.AreEqual(Post2Content1, samplePost2.Content);


            samplePost1.Content = Post1Content2;
            samplePost1         = await postsRepository.Save(samplePost1);

            Assert.AreEqual(samplePost1.Content, Post1Content2);

            findAllResult = await postsRepository.FindAll();

            Assert.IsNotEmpty(findAllResult);
            Assert.AreEqual(2, findAllResult.Count);

            var post1Found = await postsRepository.FindById(1);

            Assert.IsNotNull(post1Found);
            Assert.AreEqual(1, post1Found.PostId);
            Assert.AreEqual(Post1Title1, post1Found.Title);
            Assert.AreEqual(Post1Content2, post1Found.Content);

            var post2Found = await postsRepository.FindById(2);

            Assert.IsNotNull(post2Found);
            Assert.AreEqual(2, post2Found.PostId);
            Assert.AreEqual(Post2Title1, post2Found.Title);
            Assert.AreEqual(Post2Content1, post2Found.Content);

            var allPostsFound = await postsRepository.FindAllById(new[] { 1, 2, 1000 });

            Assert.IsNotNull(allPostsFound);
            Assert.AreEqual(2, allPostsFound.Count);
        }