Ejemplo n.º 1
0
        void MinT()
        {
            IEnumerable <DummyIComparableT> nullEnumerable = new DummyIComparableT[] { null, -1, -1, null, 0, 1, 1 };
            DummyIComparableT result = null;

            Test.IfNot.Action.ThrowsException(() => result = nullEnumerable.MinimumT(), out Exception ex);
            Test.If.Value.IsEqual(result, -1);
        }
        void Clamp(Int32 v, Int32?min, Int32?max, Int32 expected)
        {
            DummyIComparableT result = default;
            DummyIComparableT _v     = new DummyIComparableT(v);
            DummyIComparableT _min   = min.HasValue ? new DummyIComparableT(min.Value) : null;
            DummyIComparableT _max   = max.HasValue ? new DummyIComparableT(max.Value) : null;

            Test.IfNot.Action.ThrowsException(() => result = _v.Clamp(_min, _max), out Exception ex);
            Test.If.Value.IsEqual(result.Value, expected);
        }
        void IsClampedExclusive(Int32 v, Int32?min, Int32?max, Boolean expected)
        {
            Boolean           result = default;
            DummyIComparableT _v     = new DummyIComparableT(v);
            DummyIComparableT _min   = min.HasValue ? new DummyIComparableT(min.Value) : null;
            DummyIComparableT _max   = max.HasValue ? new DummyIComparableT(max.Value) : null;

            Test.IfNot.Action.ThrowsException(() => result = _v.IsClampedExclusive(_min, _max), out Exception ex);
            Test.If.Value.IsEqual(result, expected);
        }
Ejemplo n.º 4
0
        void MinT_ThrowsException()
        {
            IEnumerable <DummyIComparableT> empty = Enumerable.Empty <DummyIComparableT>();
            IEnumerable <DummyIComparableT> nulls = new DummyIComparableT[] { null, null };

            Test.If.Action.ThrowsException(() => IEnumerableTExtensions.MinimumT <DummyIComparableT>(null), out ArgumentNullException ex);
            Test.If.Value.IsEqual(ex.ParamName, "_this");

            Test.If.Action.ThrowsException(() => empty.MinimumT(), out ArgumentException argEx);
            Test.If.Value.IsEqual(argEx.ParamName, "_this");
            Test.If.String.StartsWith(argEx.Message, "The enumeration is empty.");

            Test.If.Action.ThrowsException(() => nulls.MinimumT(), out argEx);
            Test.If.Value.IsEqual(argEx.ParamName, "_this");
            Test.If.String.StartsWith(argEx.Message, "The enumeration only contains null values.");
        }