public async Task <RiskConstraintResolution> ApplyAsync( string blockchainType, string blockchainAssetId, OperationType?operationType, Operation operation) { var operationsCount = await _statisticsRepository.GetOperationsCountForTheLastPeriodAsync( blockchainType, blockchainAssetId, operationType, _period); return(operationsCount + 1 > _maxOperationsCount ? RiskConstraintResolution.Violated($"Operations count {operationsCount} + 1 > {_maxOperationsCount} for the last {_period}") : RiskConstraintResolution.Passed); }
public async Task ShouldCalculateOperationsCountForTheLastPeriod() { // Arrange await Arrange(); // Act var stopwatch = Stopwatch.StartNew(); var count = await _statistics.GetOperationsCountForTheLastPeriodAsync(_blockchain, _asset, _type, DateTime.UtcNow - _startedAt); stopwatch.Stop(); _output.WriteLine($"{nameof(IStatisticsRepository.GetOperationsCountForTheLastPeriodAsync)}\t{stopwatch.Elapsed}"); // Assert Assert.Equal(_operations.Count(), count); }