Пример #1
0
        void MaxT()
        {
            IEnumerable <DummyIComparableT> nullEnumerable = new DummyIComparableT[] { null, -1, -1, null, 0, 1, 1 };
            DummyIComparableT result = null;

            Test.IfNot.Action.ThrowsException(() => result = nullEnumerable.MaximumT(), out Exception ex);
            Test.If.Value.IsEqual(result, 1);
        }
Пример #2
0
        void MaxT_ThrowsException()
        {
            IEnumerable <DummyIComparableT> empty = Enumerable.Empty <DummyIComparableT>();
            IEnumerable <DummyIComparableT> nulls = new DummyIComparableT[] { null, null };

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

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