public static Exception ToThrow(this IExpectation <Action> expectation)
        {
            var exception = Capture(expectation.Actual);

            ExpectationHelper.PassFail(exception != null, expectation);

            return(exception);
        }
        public static T ToThrow <T>(this IExpectation <Action> expectation)
            where T : Exception
        {
            var typeOfT   = typeof(T);
            var exception = Capture(expectation.Actual);

            ExpectationHelper.PassFail(exception != null && typeOfT.IsAssignableFrom(exception.GetType()), expectation, typeOfT.FullName);

            return((T)exception);
        }
        public static void ToMatch(this IExpectation <string> expectation, string pattern, RegexOptions options)
        {
            var regex = new Regex(pattern, options);

            ExpectationHelper.PassFail(regex.IsMatch(expectation.Actual), expectation, pattern.ToString());
        }
 public static void ToMatch(this IExpectation <string> expectation, Regex pattern)
 {
     ExpectationHelper.PassFail(pattern.IsMatch(expectation.Actual), expectation, pattern.ToString());
 }
        /// <summary>
        /// Matcher that passes if the actual ends with the expected.
        /// </summary>
        /// <param name="expectation">The expectation.</param>
        /// <param name="expected">The expected value.</param>
        public static void ToEndWith(this IExpectation <string> expectation, string expected)
        {
            var pass = expectation.Actual != null && expectation.Actual.EndsWith(expected);

            ExpectationHelper.PassFail(pass, expectation, expected);
        }
        /// <summary>
        /// Matcher that passes if the actual contains the expected.
        /// </summary>
        /// <param name="expectation">The expectation.</param>
        /// <param name="expected">The expected value.</param>
        public static void ToContain(this IExpectation <string> expectation, string expected)
        {
            var pass = expectation.Actual != null && expectation.Actual.Contains(expected);

            ExpectationHelper.PassFail(pass, expectation, expected);
        }
예제 #7
0
 public static void ToContain <E, T>(this IExpectation <E> expectation, Func <T, bool> predicate)
     where E : IEnumerable <T>
 {
     ExpectationHelper.PassFail(expectation.Actual.Any(predicate), expectation, predicate.ToString());
 }
예제 #8
0
 public static void ToBeEmpty <E>(this IExpectation <E> expectation)
     where E : IEnumerable
 {
     ExpectationHelper.PassFail(!expectation.Actual.GetEnumerator().MoveNext(), expectation);
 }
예제 #9
0
 public static void ToContain <E, T>(this IExpectation <E> expectation, T expected)
     where E : IEnumerable <T>
 {
     ExpectationHelper.PassFail(expectation.Actual.Contains(expected), expectation, expected.ToString());
 }
 public static void ToBeEmpty <TItem>(this IExpectation <IEnumerable <TItem> > expectation)
 {
     ExpectationHelper.PassFail(!expectation.Actual.Any(), expectation);
 }
 public static void ToContain <TItem>(this IExpectation <IEnumerable <TItem> > expectation, Func <TItem, bool> predicate)
 {
     ExpectationHelper.PassFail(expectation.Actual.Any(predicate), expectation, predicate.ToString());
 }
 public static void ToContain <TItem>(this IExpectation <IEnumerable <TItem> > expectation, TItem expected)
 {
     ExpectationHelper.PassFail(expectation.Actual.Contains(expected), expectation, expected.ToString());
 }
예제 #13
0
 public static void ToContainKey(this IExpectation <IDictionary> expectation, object key)
 {
     ExpectationHelper.PassFail(expectation.Actual.Contains(key), expectation, key.ToString());
 }