public async Task Delete_RoleNotFound_AsksForErrorView()
        {
            Mock <RoleStore <AppRole> > roleStore   = new Mock <RoleStore <AppRole> >();
            Mock <AppRoleManager>       roleManager = new Mock <AppRoleManager>(roleStore.Object);

            roleManager.Setup(m => m.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(null as AppRole);
            RoleAdminController controller = GetNewRoleAdminController(null, roleManager.Object);

            ViewResult result = (await controller.Delete("")) as ViewResult;

            Assert.AreEqual("Error", result.ViewName);
            string[] model = result.ViewData.Model as string[];
            Assert.AreEqual("Роль не найдена", model[0]);
        }
        public async Task Delete_RoleFoundAndIdentityResultSucceeded_RedirectToIndex()
        {
            Mock <RoleStore <AppRole> > roleStore   = new Mock <RoleStore <AppRole> >();
            Mock <AppRoleManager>       roleManager = new Mock <AppRoleManager>(roleStore.Object);

            roleManager.Setup(m => m.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(new AppRole {
            });
            roleManager.Setup(m => m.DeleteAsync(It.IsAny <AppRole>())).ReturnsAsync(IdentityResult.Success);
            RoleAdminController controller = GetNewRoleAdminController(null, roleManager.Object);

            RedirectToRouteResult result = (await controller.Delete("")) as RedirectToRouteResult;

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
        public async Task Delete_RoleFoundAndIdentityResultNotSucceeded_AsksForErrorView()
        {
            Mock <RoleStore <AppRole> > roleStore   = new Mock <RoleStore <AppRole> >();
            Mock <AppRoleManager>       roleManager = new Mock <AppRoleManager>(roleStore.Object);

            roleManager.Setup(m => m.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(new AppRole {
            });
            roleManager.Setup(m => m.DeleteAsync(It.IsAny <AppRole>())).ReturnsAsync(IdentityResult.Failed("Delete Error"));
            RoleAdminController controller = GetNewRoleAdminController(null, roleManager.Object);

            ViewResult result = (await controller.Delete("")) as ViewResult;

            Assert.AreEqual("Error", result.ViewName);
            string[] model = result.ViewData.Model as string[];
            Assert.AreEqual("Delete Error", model[0]);
        }