public void IsNot_When_different_values_It_should_not_throw()
        {
            var spec = When_value_is_lt_than_limit();

            ShouldNotThrow(
                () => Ensure.That(spec.Value, ParamName).IsNot(spec.Limit),
                () => EnsureArg.IsNot(spec.Value, spec.Limit, ParamName));
        }
        public void IsNot_When_same_values_It_throws_ArgumentException()
        {
            var spec = When_value_is_equal_to_limit();

            AssertAll <ArgumentException>(
                string.Format(ExceptionMessages.Comp_IsNot_Failed, spec.Value, spec.Limit),
                () => Ensure.That(spec.Value, ParamName).IsNot(spec.Limit),
                () => EnsureArg.IsNot(spec.Value, spec.Limit, ParamName));
        }
        public void IsNot_When_different_values_It_returns_passed_value()
        {
            var spec = When_value_is_lt_than_limit();

            var returnedValue = Ensure.That(spec.Value, ParamName).IsNot(spec.Limit);

            AssertReturnedAsExpected(returnedValue, spec.Value);

            Action a = () => EnsureArg.IsNot(spec.Value, spec.Limit, ParamName);

            a.ShouldNotThrow();
        }
Exemplo n.º 4
0
        public void IsNotEqualTo_When_different_values_by_casing_using_case_sensitive_compare_It_should_not_throw()
        {
            var value = "The value";

            ShouldNotThrow(
                () => Ensure.String.IsNotEqualTo(value, value.ToLower(), StringComparison.Ordinal, ParamName),
                () => EnsureArg.IsNotEqualTo(value, value.ToLower(), StringComparison.Ordinal, ParamName),
                () => Ensure.That(value, ParamName).IsNotEqualTo(value.ToLower(), StringComparison.Ordinal),
                () => Ensure.String.IsNot(value, value.ToLower(), StringComparison.Ordinal, ParamName),
                () => EnsureArg.IsNot(value, value.ToLower(), StringComparison.Ordinal, ParamName),
                () => Ensure.That(value, ParamName).IsNot(value.ToLower(), StringComparison.Ordinal));
        }
Exemplo n.º 5
0
        public void IsNotEqualTo_When_different_values_It_should_not_throw()
        {
            var value = "The value";

            ShouldNotThrow(
                () => Ensure.String.IsNotEqualTo(value, value + "a", ParamName),
                () => EnsureArg.IsNotEqualTo(value, value + "a", ParamName),
                () => Ensure.That(value, ParamName).IsNotEqualTo(value + "a"),
                () => Ensure.String.IsNot(value, value + "a", ParamName),
                () => EnsureArg.IsNot(value, value + "a", ParamName),
                () => Ensure.That(value, ParamName).IsNot(value + "a"));
        }
        public IdentityProvider(string name, string authority, IReadOnlyList <string> audience, string version)
        {
            EnsureArg.IsNotNull(name, nameof(name));
            EnsureArg.IsNotNull(authority, nameof(authority));
            EnsureArg.IsNotNull(audience, nameof(audience));
            EnsureArg.IsNot(version, nameof(version));

            Name      = name;
            Authority = authority;
            Audience  = audience;
            Version   = version;
        }
Exemplo n.º 7
0
        public void IsNotEqualTo_When_same_values_It_throws_ArgumentException()
        {
            const string value = "The value";

            ShouldThrow <ArgumentException>(
                string.Format(ExceptionMessages.Comp_IsNot_Failed, value, value),
                () => Ensure.String.IsNotEqualTo(value, value, ParamName),
                () => EnsureArg.IsNotEqualTo(value, value, ParamName),
                () => Ensure.That(value, ParamName).IsNotEqualTo(value),
                () => Ensure.String.IsNot(value, value, ParamName),
                () => EnsureArg.IsNot(value, value, ParamName),
                () => Ensure.That(value, ParamName).IsNot(value));
        }
Exemplo n.º 8
0
        public void IsNotEqualTo_When_different_values_by_casing_using_non_case_sensitive_compare_It_throws_ArgumentException()
        {
            const string value     = "The value";
            var          compareTo = value.ToLower();

            ShouldThrow <ArgumentException>(
                string.Format(ExceptionMessages.Comp_IsNot_Failed, value, compareTo),
                () => Ensure.String.IsNotEqualTo(value, compareTo, StringComparison.OrdinalIgnoreCase, ParamName),
                () => EnsureArg.IsNotEqualTo(value, compareTo, StringComparison.OrdinalIgnoreCase, ParamName),
                () => Ensure.That(value, ParamName).IsNotEqualTo(compareTo, StringComparison.OrdinalIgnoreCase),
                () => Ensure.String.IsNot(value, compareTo, StringComparison.OrdinalIgnoreCase, ParamName),
                () => EnsureArg.IsNot(value, compareTo, StringComparison.OrdinalIgnoreCase, ParamName),
                () => Ensure.That(value, ParamName).IsNot(compareTo, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 9
0
        public async Task <Entity.V1.Output> ExecuteAsync(Get_EntityByIdQuery.V1 query, CancellationToken ctk = default)
        {
            EnsureArg.IsNotNull(query, nameof(query));
            EnsureArg.IsNot(query.EntityId, "ensure");

            if (query.EntityId == "null")
            {
                return(null);
            }

            var entity = new Entity.V1.Output()
            {
                EntityId = query.EntityId
            };

            return(await Task.FromResult(entity));
        }
        public void IsNot_Comparer_arg_is_used()
        {
            // sa < Sb < sc when case sensitive, but not when case insensitive
            var sa = "sa";
            var Sa = "Sa";
            IComparer <string> ordinal = StringComparer.Ordinal;

            ShouldNotThrow(
                () => Ensure.That(sa, ParamName).IsNot(Sa, ordinal),
                () => EnsureArg.IsNot(sa, Sa, ordinal, ParamName));

            // Validate with comparer (order is reversed)
            IComparer <string> ignoreCase = StringComparer.OrdinalIgnoreCase;

            ShouldThrow <ArgumentException>(
                string.Format(ExceptionMessages.Comp_IsNot_Failed, sa, Sa),
                () => Ensure.That(sa, ParamName).IsNot(Sa, ignoreCase),
                () => EnsureArg.IsNot(sa, Sa, ignoreCase, ParamName));
        }
Exemplo n.º 11
0
 public RKiss(ulong s)
 {
     EnsureArg.IsNot(s, 0ul, nameof(s));
     _s = s;
 }