public void ArrayToCollection() { var intArrayArgType = new ArrayArgumentType(typeof(int[])); Action invocation = () => intArrayArgType.ToCollection(null); invocation.ShouldThrow <ArgumentNullException>(); var outCollection = intArrayArgType.ToCollection(new ArrayList(new[] { 10, -1 })); outCollection.Should().BeOfType <int[]>(); var outList = (int[])outCollection; outList.Length.Should().Be(2); outList[0].Should().Be(10); outList[1].Should().Be(-1); }
public void RegisterCommandGeneric_ReadMultipleParamsIntoArray_WhenAllowMultiple() { ArrayArgumentType a = null; Cli .Configure(c => c .SetDialect(Dialect.Gnu) .DisableExceptionHandling()) .Root <ArrayArgumentType>(c => c.SetExecute((args, output) => a = args) ).Run(new[] { "--int-array", "1", "--int-array", "2", "--int-array", "3" }); Assert.Equal(new[] { 1, 2, 3 }, a.Option); }