Beispiel #1
0
        public void GenericConvert_TypeConversionIsNull_ArgumentNullExc()
        {
            // arrange
            var list = new[] { "Foo", "Bar" };

            // act
            Action action = () =>
                            TypeConversionExtensions.Convert <string[], List <FooOrBar?> >(
                null, list);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Beispiel #2
0
        public void GenericTryConvert_ArrayOfString_NullableListOfFooOrBar()
        {
            // arrange
            var list = new[] { "Foo", "Bar" };

            // act
            bool success =
                TypeConversionExtensions.TryConvert <string[], List <FooOrBar?> >(
                    TypeConversion.Default,
                    list, out var output);

            // assert
            Assert.True(success);
            Assert.IsType <List <FooOrBar?> >(output);
            Assert.Collection((List <FooOrBar?>)output,
                              t => Assert.Equal(FooOrBar.Foo, t),
                              t => Assert.Equal(FooOrBar.Bar, t));
        }