public async Task InvalidDelete()
        {
            // Arrange
            Moq.Mock <IBloggingRepository> mock       = MockBloggingRepository();
            IBloggingRepository            repository = mock.Object;
            var logger = LoggerFactory.CreateLogger <BlogsController>();

            //1st add one object
            await repository.AddAsync(new Blog
            {
                BlogId = 99999,
                Post   = null,
                Url    = "http://www.99999.com",
            });

            await repository.SaveAsync();

            using (IBlogsController controller = new BlogsController(repository, logger, Configuration, DataProtectionProvider))
            {
                var model = new DecoratedBlog
                {
                    BlogId      = 99999,
                    Post        = null,
                    Url         = "bad_url_but_no_matter",
                    ProtectedID = "giberish"
                };

                // Act
                var result = await controller.ItemAction(model, true, BlogActionEnum.Delete);

                // Assert
                Assert.IsType <NotFoundResult>(result);
                Assert.Equal(404, ((NotFoundResult)result).StatusCode);
            }
        }
        public async Task InvalidEdit()
        {
            // Arrange
            Moq.Mock <IBloggingRepository> mock       = MockBloggingRepository();
            IBloggingRepository            repository = mock.Object;
            var logger = LoggerFactory.CreateLogger <BlogsController>();

            //1st add one object
            await repository.AddAsync(new Blog
            {
                BlogId = -99999,
                Post   = null,
                Url    = "http://www.999999.com",
            });

            await repository.SaveAsync();

            using (IBlogsController controller = new BlogsController(repository, logger, Configuration, DataProtectionProvider))
            {
                var model = new DecoratedBlog
                {
                    BlogId      = -99999,
                    Post        = null,
                    Url         = "http://www.minus999999.com",
                    ProtectedID = "giberish"
                };

                // Act
                ((Controller)controller).ModelState.AddModelError(nameof(Blog.Url), "bad id");

                var result = await controller.ItemAction(model, true, BlogActionEnum.Edit);

                // Assert
                Assert.IsType <JsonResult>(result);
                Assert.IsType <string>(((JsonResult)result).Value);
                Assert.Equal("error", ((JsonResult)result).Value.ToString());
            }
        }
        public async Task Edit()
        {
            // Arrange
            Moq.Mock <IBloggingRepository> mock       = MockBloggingRepository();
            IBloggingRepository            repository = mock.Object;
            var logger = LoggerFactory.CreateLogger <BlogsController>();

            //1st add one object
            await repository.AddAsync(new Blog
            {
                BlogId = 2,
                Post   = null,
                Url    = "http://www.internet.com",
            });

            await repository.SaveAsync();

            using (IBlogsController controller = new BlogsController(repository, logger, Configuration, DataProtectionProvider))
            {
                var model = new DecoratedBlog
                {
                    BlogId      = 2,
                    Post        = null,
                    Url         = "http://www.changed-internet.com",
                    ProtectedID = "giberish"
                };

                // Act
                var result = await controller.ItemAction(model, true, BlogActionEnum.Edit);

                // Assert
                Assert.IsType <JsonResult>(result);
                Assert.IsType <Blog>(((JsonResult)result).Value);
                Assert.Equal(2, ((Blog)((JsonResult)result).Value).BlogId);
                Assert.Contains("changed", ((Blog)((JsonResult)result).Value).Url);
            }
        }