示例#1
0
 /// <summary>
 /// Creates expectation for collections to equal sequence specified by <paramref name="collection"/> parameter.
 /// </summary>
 /// <typeparam name="T">Expectation value type</typeparam>
 /// <param name="composer">Composer</param>
 /// <param name="collection">Expected collection</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="collection"/> is null.</exception>
 public static Expectation <IEnumerable <T> > EqualCollection <T>(this IExpectationComposer composer, IEnumerable <T> collection)
 {
     if (collection == null)
     {
         throw new ArgumentNullException(nameof(collection));
     }
     return(composer.Compose(new EqualCollection <T>(collection)));
 }
示例#2
0
 /// <summary>
 /// Helper method creating simple expectation based on <paramref name="predicateFn"/> and <paramref name="descriptionFn"/>.
 /// </summary>
 /// <typeparam name="T">Expectation value type</typeparam>
 /// <param name="composer">Composer</param>
 /// <param name="descriptionFn">Expectation description</param>
 /// <param name="predicateFn">Expectation predicate</param>
 public static Expectation <T> ComposeSimple <T>(this IExpectationComposer composer, Func <IValueFormattingService, string> descriptionFn, Func <T, bool> predicateFn)
 {
     return(composer.Compose(new SimpleExpectation <T>(descriptionFn, predicateFn)));
 }
示例#3
0
 /// <summary>
 /// Creates expectation for values to fulfill any expectation specified by <paramref name="expectationBuilder"/> parameter.
 /// </summary>
 /// <typeparam name="T">Expectation value type</typeparam>
 /// <param name="composer">Composer</param>
 /// <param name="expectationBuilder">Expectation builder</param>
 public static Expectation <T> BeAnyTrue <T>(this IExpectationComposer composer, params Func <IExpectationComposer, IExpectation <T> >[] expectationBuilder)
 {
     return(composer.Compose(new OrExpectation <T>("any true ", expectationBuilder.Select(x => x.Invoke(Expect.To)).ToArray())));
 }
示例#4
0
 /// <summary>
 /// Creates expectation for collections with every item fulfilling expectation specified by <paramref name="expectationBuilder"/> parameter.
 /// </summary>
 /// <typeparam name="T">Expectation value type</typeparam>
 /// <param name="composer">Composer</param>
 /// <param name="expectationBuilder">Expectation builder</param>
 public static Expectation <IEnumerable <T> > EveryItem <T>(this IExpectationComposer composer, Func <IExpectationComposer, IExpectation <T> > expectationBuilder)
 {
     return(composer.Compose(new EveryItemExpectation <T>(expectationBuilder.Invoke(Expect.To))));
 }