Exemplo n.º 1
0
 public static ContinuationOfGiven <T[]> AssertCollectionHasEnoughItems <T>(this GivenSelector <IEnumerable <T> > givenSelector,
                                                                            int length)
 {
     return(givenSelector
            .Given(items => items.ToArray())
            .AssertCollectionHasEnoughItems(length));
 }
Exemplo n.º 2
0
 public static ContinuationOfGiven <T[]> AssertCollectionHasEnoughItems <T>(this GivenSelector <T[]> givenSelector, int length)
 {
     return(givenSelector
            .Given(items => items.ToArray())
            .ForCondition(items => items.Length >= length)
            .FailWith("but {0} contains {1} item(s) less.", items => items, items => length - items.Length));
 }
Exemplo n.º 3
0
 public static ContinuationOfGiven <IEnumerable <T> > AssertCollectionIsNotNull <T>(
     this GivenSelector <IEnumerable <T> > givenSelector)
 {
     return(givenSelector
            .ForCondition(items => !ReferenceEquals(items, null))
            .FailWith("but found collection is <null>."));
 }
Exemplo n.º 4
0
 public static ContinuationOfGiven <IEnumerable <T> > AssertEitherCollectionIsNotEmpty <T>(
     this GivenSelector <IEnumerable <T> > givenSelector, int length)
 {
     return(givenSelector
            .ForCondition(items => !EitherIsEmpty(length, items.Count()))
            .FailWith("but found empty collection."));
 }
Exemplo n.º 5
0
 public static ContinuationOfGiven <IEnumerable <T> > AssertCollectionIsNotNullOrEmpty <T>(
     this GivenSelector <IEnumerable <T> > givenSelector, int length)
 {
     return(givenSelector
            .AssertCollectionIsNotNull()
            .Then
            .AssertEitherCollectionIsNotEmpty(length));
 }
Exemplo n.º 6
0
 public static void AssertCollectionsHaveSameItems <TActual, TExpected>(this GivenSelector <TActual[]> givenSelector,
                                                                        TExpected[] expected, Func <TActual[], TExpected[], int> findIndex)
 {
     givenSelector
     .Given(actual => new { Items = actual, Index = findIndex(actual, expected) })
     .ForCondition(diff => diff.Index == -1)
     .FailWith("but {0} differs at index {1}.", diff => diff.Items, diff => diff.Index);
 }
Exemplo n.º 7
0
 public static ContinuationOfGiven <T[]> AssertCollectionsHaveSameCount <T>(this GivenSelector <IEnumerable <T> > givenSelector,
                                                                            int length)
 {
     return(givenSelector
            .AssertEitherCollectionIsNotEmpty(length)
            .Then
            .AssertCollectionHasEnoughItems(length)
            .Then
            .AssertCollectionHasNotTooManyItems(length));
 }
 public static ContinuationOfGiven <ICollection <T> > AssertEitherCollectionIsNotEmpty <T>(
     this GivenSelector <ICollection <T> > givenSelector, int length)
 {
     return(givenSelector
            .ForCondition(items => ((items.Count > 0) || (length == 0)))
            .FailWith("but found empty collection.")
            .Then
            .ForCondition(items => ((items.Count == 0) || (length > 0)))
            .FailWith("but found {0}.", items => items));
 }
Exemplo n.º 9
0
 public static ContinuationOfGiven <T[]> AssertCollectionHasNotTooManyItems <T>(this GivenSelector <T[]> givenSelector,
                                                                                int length)
 {
     return(givenSelector
            .Given(items => items.ToArray())
            .ForCondition(items => items.Length <= length)
            .FailWith("but {0} contains {1} item(s) too many.", items => items, items => items.Length - length));
 }
 public static ContinuationOfGiven <ICollection <TActual> > AssertCollectionsHaveSameItems <TActual, TExpected>(this GivenSelector <ICollection <TActual> > givenSelector,
                                                                                                                ICollection <TExpected> expected, Func <ICollection <TActual>, ICollection <TExpected>, int> findIndex)
 {
     return(givenSelector
            .Given <ICollection <TActual> >(actual => new CollectionWithIndex <TActual>(actual, findIndex(actual, expected)))
            .ForCondition(diff => diff.As <CollectionWithIndex <TActual> >().Index == -1)
            .FailWith("but {0} differs at index {1}.",
                      diff => diff.As <CollectionWithIndex <TActual> >().Items,
                      diff => diff.As <CollectionWithIndex <TActual> >().Index));
 }
 public static ContinuationOfGiven <ICollection <T> > AssertCollectionHasNotTooManyItems <T>(this GivenSelector <ICollection <T> > givenSelector,
                                                                                             int length)
 {
     return(givenSelector
            .ForCondition(items => items.Count <= length)
            .FailWith("but {0} contains {1} item(s) too many.", items => items, items => items.Count - length));
 }
 public static ContinuationOfGiven <ICollection <T> > AssertCollectionHasEnoughItems <T>(this GivenSelector <ICollection <T> > givenSelector, int length)
 {
     return(givenSelector
            .ForCondition(items => items.Count >= length)
            .FailWith("but {0} contains {1} item(s) less.", items => items, items => length - items.Count));
 }
 public static ContinuationOfGiven <ICollection <T> > AssertCollectionHasEnoughItems <T>(this GivenSelector <IEnumerable <T> > givenSelector,
                                                                                         int length)
 {
     return(givenSelector
            .Given(items => items.ConvertOrCastToCollection())
            .AssertCollectionHasEnoughItems(length));
 }