Ejemplo n.º 1
0
        public SecretWrapper(string secretName, string secretValue)
        {
            EnsureArg.IsNotNullOrWhiteSpace(secretName, nameof(secretName));
            EnsureArg.IsNotEmptyOrWhitespace(secretValue, nameof(secretValue));

            SecretName  = secretName;
            SecretValue = secretValue;
        }
        public void AddResourceVersionPolicy(string policy)
        {
            EnsureArg.IsNotEmptyOrWhitespace(policy, nameof(policy));

            var versionPolicy = policy.GetValueByEnumLiteral <ResourceVersionPolicy>();

            Versioning.Add(versionPolicy);
        }
Ejemplo n.º 3
0
        public void IsNotEmptyOrWhitespace_WhenNull_It_should_not_throw()
        {
            string value = null;

            ShouldNotThrow(
                () => Ensure.String.IsNotEmptyOrWhitespace(value, ParamName),
                () => Ensure.That(value, ParamName).IsNotEmptyOrWhitespace(),
                () => EnsureArg.IsNotEmptyOrWhitespace(value, ParamName));
        }
Ejemplo n.º 4
0
        public void IsNotEmptyOrWhitespace_WhenPartialWhitespace_It_should_not_throw()
        {
            string value = "  string with whitespace in it  ";

            ShouldNotThrow(
                () => Ensure.String.IsNotEmptyOrWhitespace(value, ParamName),
                () => EnsureArg.IsNotEmptyOrWhitespace(value, ParamName),
                () => Ensure.That(value, ParamName).IsNotEmptyOrWhitespace());
        }
Ejemplo n.º 5
0
        public void IsNotEmptyOrWhitespace_WhenWhitespace_ThrowsArgumentException()
        {
            string value = "        ";

            ShouldThrow <ArgumentException>(
                ExceptionMessages.Strings_IsNotEmptyOrWhitespace_Failed,
                () => Ensure.String.IsNotEmptyOrWhitespace(value, ParamName),
                () => Ensure.That(value, ParamName).IsNotEmptyOrWhitespace(),
                () => EnsureArg.IsNotEmptyOrWhitespace(value, ParamName));
        }
        public QueryHelper(StringBuilder queryBuilder, QueryParameterManager queryParameterManager, string rootAliasName)
        {
            EnsureArg.IsNotNull(queryBuilder, nameof(queryBuilder));
            EnsureArg.IsNotNull(queryParameterManager, nameof(queryParameterManager));
            EnsureArg.IsNotEmptyOrWhitespace(rootAliasName, nameof(queryParameterManager));

            _queryBuilder          = queryBuilder;
            _queryParameterManager = queryParameterManager;
            _rootAliasName         = rootAliasName;
        }
        public string ResolveSystem(string shortPath)
        {
            EnsureArg.IsNotEmptyOrWhitespace(shortPath, nameof(shortPath));

            if (_dictionary == null)
            {
                throw new InvalidOperationException($"{nameof(CodeSystemResolver)} has not been initialized.");
            }

            if (_dictionary.TryGetValue(NormalizePath(shortPath), out var system))
            {
                return(system);
            }

            return(null);
        }
Ejemplo n.º 8
0
        public Variable Parse(string variable)
        {
            EnsureArg.IsNotEmptyOrWhitespace(variable, nameof(variable));

            _logger.Log(
                TraceLevel.Info,
                $"Start parsing variable {variable}");

            var parts = variable.Split('^');

            var letter = Convert.ToChar(parts[0]);

            if (parts.Length > 1)
            {
                var power = Convert.ToDecimal(parts[1]);

                return(new Variable(letter, power));
            }

            return(new Variable(letter));
        }
Ejemplo n.º 9
0
        public static void Validate(string fen)
        {
            EnsureArg.IsNotEmptyOrWhitespace(fen, nameof(fen));

            var f = fen.Trim().AsSpan();

            if (f.Length <= MaxFenLen)
            {
                throw new InvalidFenException($"Invalid length for fen {fen}.");
            }

            if (!ValidFenRegex.Value.IsMatch(fen))
            {
                throw new InvalidFenException($"Invalid format for fen {fen}.");
            }

            CountValidity(f);
            if (!CountPieceValidity(f))
            {
                throw new InvalidFenException($"Invalid piece validity for fen {fen}");
            }
        }
Ejemplo n.º 10
0
        public Stream GetSettingsFile(string name)
        {
            EnsureArg.IsNotEmptyOrWhitespace(name, nameof(name));

            return(File.OpenRead(Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), name)));
        }
        public void UseConnectionString(string connectionString)
        {
            EnsureArg.IsNotEmptyOrWhitespace(connectionString);

            Options.ConnectionString = connectionString;
        }