Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public void ShouldThrowExceptionWhenNotNullCheckNullValue()
        {
            var action = new Action(() => Should.NotNull(null, () => new InvalidOperationException()));

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