예제 #1
0
 public static ContinuationOfGiven <T[]> AssertCollectionDoesNotMissItems <T>(this GivenSelector <T[]> givenSelector, IEnumerable <T> expected, string message = null)
 {
     message = message ?? "but could not find item(s) {0}.";
     return(givenSelector
            .ForCondition(items => !expected.Except(items).Any())
            .FailWith(message, expected.Except));
 }
예제 #2
0
 public static ContinuationOfGiven <T[]> AssertDictionaryDoesNotHaveAdditionalItems <T>(this GivenSelector <T[]> givenSelector, IEnumerable <T> expected, string message = null)
 {
     message = message ?? "but found additional item(s) {0}.";
     return(givenSelector
            .ForCondition(items => !items.Except(expected).Any())
            .FailWith(message, items => items.Except(expected)));
 }
예제 #3
0
 public static ContinuationOfGiven <IDictionary <TKey, TValue> > AssertDictionaryIsNotEmpty <TKey, TValue>(this GivenSelector <IDictionary <TKey, TValue> > givenSelector, bool isNotEmpty = true, string message = null)
 {
     message = message ?? "but found empty dictionary.";
     return(givenSelector
            .ForCondition(items => items.Any())
            .FailWith(message));
 }
예제 #4
0
 public static ContinuationOfGiven <IEnumerable <T> > AssertCollectionIsNotEmpty <T>(this GivenSelector <IEnumerable <T> > givenSelector, bool isNotEmpty = true, string message = null)
 {
     message = message ?? "but found empty collection.";
     return(givenSelector
            .ForCondition(items => items.Any() || !isNotEmpty)
            .FailWith(message));
 }
예제 #5
0
 public static ContinuationOfGiven <IDictionary <TKey, TValue> > AssertDictionaryIsNotNull <TKey, TValue>(this GivenSelector <IDictionary <TKey, TValue> > givenSelector, string message = null)
 {
     message = message ?? "but found dictionary is <null>.";
     return(givenSelector
            .ForCondition(items => !ReferenceEquals(items, null))
            .FailWith(message));
 }
예제 #6
0
 public static ContinuationOfGiven <Arr> AssertEitherArrHaveSameSizeAndElementType(this GivenSelector <Arr> givenSelector, Size size, int elementType) =>
 givenSelector
 .ForCondition(items => items.Size != size)
 .FailWith("but found size {0}.", items => items.Size)
 .Then
 .ForCondition(items => items.ElementType != elementType)
 .FailWith("but found {0}.", items => items.ElementType);
예제 #7
0
 public static ContinuationOfGiven <IDictionary <TKey, TValue> > AssertDictionaryDoesNotHaveAdditionalKeys <TKey, TValue>(this GivenSelector <IDictionary <TKey, TValue> > givenSelector, IDictionary <TKey, TValue> expected, string message = null, params Func <IDictionary <TKey, TValue>, object>[] args)
 {
     message = message ?? "but found additional keys {0}.";
     args    = (args != null && args.Length > 0) ? args : new[] { new Func <IDictionary <TKey, TValue>, object>(items => items.Keys.Except(expected.Keys)) };
     return(givenSelector
            .ForCondition(items => !items.Keys.Except(expected.Keys).Any())
            .FailWith(message, args));
 }
 private static ContinuationOfGiven <TActual[]> AssertCollectionLength <TActual, TExpected>(this GivenSelector <TActual[]> givenSelector, TActual[] actualItems, TExpected[] expectedItems)
 {
     return(givenSelector.ForCondition(items => items.Length > 0)
            .FailWith("but the collection is empty.")
            .Then
            .ForCondition(items => items.Length >= expectedItems.Length)
            .FailWith("but {0} contains {1} item(s) less.", actualItems, expectedItems.Length - actualItems.Length));
 }
예제 #9
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>."));
 }