Exemplo n.º 1
0
 /// <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);
 }
Exemplo n.º 2
0
 private void MapErrorsToModelState(string key, IdentityServiceResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError(key, error.Description);
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Asserts that the result has not Succeeded.
 /// </summary>
 public static void IsFailure(IdentityServiceResult result)
 {
     Assert.NotNull(result);
     Assert.False(result.Succeeded);
 }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 public Task <IdentityServiceResult> ValidateClaimAsync(ApplicationManager <TApplication> manager, TApplication application, Claim claim)
 {
     return(Task.FromResult(claim.Type.Equals("fail") ? IdentityServiceResult.Failed(new IdentityServiceError()) : IdentityServiceResult.Success));
 }