/// <summary> /// Asserts that the result has not Succeeded and that first error matches error's code and Description. /// </summary> public static void IsFailure(IdentityServiceResult result, IdentityServiceError error) { Assert.NotNull(result); Assert.False(result.Succeeded); Assert.Equal(error.Description, result.Errors.First().Description); Assert.Equal(error.Code, result.Errors.First().Code); }
private void MapErrorsToModelState(string key, IdentityServiceResult result) { foreach (var error in result.Errors) { ModelState.AddModelError(key, error.Description); } }
public async Task <IdentityServiceResult> DeleteAsync(TApplication application, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (application == null) { throw new ArgumentNullException(nameof(application)); } Context.Remove(application); try { await SaveChanges(cancellationToken); } catch (DbUpdateConcurrencyException) { return(IdentityServiceResult.Failed(ErrorDescriber.ConcurrencyFailure())); } return(IdentityServiceResult.Success); }
/// <summary> /// Asserts that the result has not Succeeded. /// </summary> public static void IsFailure(IdentityServiceResult result) { Assert.NotNull(result); Assert.False(result.Succeeded); }
/// <summary> /// Asserts that the result has Succeeded. /// </summary> /// <param name="result"></param> public static void IsSuccess(IdentityServiceResult result) { Assert.NotNull(result); Assert.True(result.Succeeded); }
public Task <IdentityServiceResult> ValidateClaimAsync(ApplicationManager <TApplication> manager, TApplication application, Claim claim) { return(Task.FromResult(claim.Type.Equals("fail") ? IdentityServiceResult.Failed(new IdentityServiceError()) : IdentityServiceResult.Success)); }