public void AssignRolePermission_Success() { // Act var lstRolePermissionsViewModel = new List <RolePermissionsViewModel>(); var rolePermissionsViewModel = new RolePermissionsViewModel(); var role = new RoleViewModel(); role.RoleID = 1; rolePermissionsViewModel.Role = role; var modules = new List <ModuleViewModel>(); var permissions = new List <PermissionViewModel>(); permissions.Add(new PermissionViewModel() { PermissionID = 1 }); rolePermissionsViewModel.Modules = modules; modules.Add(new ModuleViewModel() { ModuleID = 1, Permissions = permissions }); lstRolePermissionsViewModel.Add(new RolePermissionsViewModel { Role = role, Modules = modules }); var features = new List <FeatureViewModel>(); var permissionFeature = new List <PermissionViewModel>(); permissionFeature.Add(new PermissionViewModel() { PermissionID = 1 }); features.Add(new FeatureViewModel() { FeatureID = 1, Permissions = permissionFeature }); rolePermissionsViewModel.Features = features; lstRolePermissionsViewModel.Add(new RolePermissionsViewModel { Role = role, Features = features }); var result = controller.AssignRolePermission(rolePermissionsViewModel); var jsonResponse = result as JsonResult; var data = result.Data; var modelResponse = data as Response <RolePermissionsViewModel>; var rowAffected = modelResponse.RowAffected; // Assert Assert.IsTrue(rowAffected > 0); }