public static IEnumerable <TTarget> DynamicMap <TTarget>(this IEnumerable sources)
            where TTarget : class, new()
        {
            if (sources == null)
            {
                return(null);
            }
            var sourceItemType = sources.GetType().GetEnumerableItemType();

            Should.NotNull(sourceItemType, () => new InvalidOperationException($"can not judge source item type, source should be generic type '{typeof(IEnumerable<>)}'."));
            return(Invoke <IEnumerable <TTarget> >(sourceItemType, typeof(TTarget), "map-enumerable", sources));
        }
Exemple #2
0
        public void ShouldThrowExceptionWhenNotNullCheckNullValue()
        {
            var action = new Action(() => Should.NotNull(null, () => new InvalidOperationException()));

            action.Should().Throw <InvalidOperationException>();
        }
Exemple #3
0
 public void ShouldNotThrowExceptionWhenNotNullCheckNotNullValue()
 {
     Should.NotNull("", () => new CodeException());
     Should.NotNull(1, () => new CodeException());
     Should.NotNull(new object(), () => new CodeException());
 }
Exemple #4
0
 public void ShouldThrowExceptionWhenNotNullCheckNullValue()
 {
     Should.NotNull(null, () => new InvalidOperationException());
 }