Beispiel #1
0
        void Min()
        {
            IEnumerable <DummyIComparable> nullEnumerable = new DummyIComparable[] { null, -1, -1, null, 0, 1, 1 };
            DummyIComparable result = null;

            Test.IfNot.Action.ThrowsException(() => result = nullEnumerable.Minimum(), out Exception ex);
            Test.If.Value.IsEqual(result, -1);
        }
Beispiel #2
0
        void Min_ThrowsException()
        {
            IEnumerable <DummyIComparable> empty = Enumerable.Empty <DummyIComparable>();
            IEnumerable <DummyIComparable> nulls = new DummyIComparable[] { null, null };

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

            Test.If.Action.ThrowsException(() => empty.Minimum(), 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.Minimum(), out argEx);
            Test.If.Value.IsEqual(argEx.ParamName, "_this");
            Test.If.String.StartsWith(argEx.Message, "The enumeration only contains null values.");
        }