public async Task ExecuteAsync_Success(Mock <ICacheItemRepository> cacheItemRepository, ApproveActionRequest request) { var command = new ApproveActionCommand(cacheItemRepository.Object); await command.ExecuteAsync(request); cacheItemRepository.Verify(x => x.UpdateAsync(request.Context, It.IsAny <Action <CacheItem> >(), null), Times.Once); }
public async Task ExecuteAsync_Fail_EmptyNonce(Mock <ICacheItemRepository> cacheItemRepository, ApproveActionRequest request) { const string errorMessage = "Context and nonce are required"; request.Nonce = null; var command = new ApproveActionCommand(cacheItemRepository.Object); await command.Invoking(x => x.ExecuteAsync(request)).Should().ThrowAsync <CommandValidationException>() .WithMessage(errorMessage); request.Nonce = string.Empty; await command.Invoking(x => x.ExecuteAsync(request)).Should().ThrowAsync <CommandValidationException>() .WithMessage(errorMessage); }
public ApproveActionMiddleware(RequestDelegate next, ApproveActionCommand approveActionCommand, ILogger <ApproveActionMiddleware> logger) : base(next, logger) { _approveActionCommand = approveActionCommand; }