Exemplo n.º 1
0
        private async Task <IWatcherCheckResult> ExecuteForQueryAsync(IRedis redis)
        {
            var queryResult = await redis.QueryAsync(_configuration.Query);

            var isValid = true;

            if (_configuration.EnsureThatAsync != null)
            {
                isValid = await _configuration.EnsureThatAsync?.Invoke(queryResult);
            }

            isValid = isValid && (_configuration.EnsureThat?.Invoke(queryResult) ?? true);
            var description = $"Redis check has returned {(isValid ? "valid" : "invalid")} result for " +
                              $"database: '{_configuration.Database}' and given query.";

            return(RedisWatcherCheckResult.Create(this, isValid, _configuration.Database,
                                                  _configuration.ConnectionString, _configuration.Query, queryResult, description));
        }