예제 #1
0
        public void GetTyped()
        {
            Assert.Equal(5, ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5).Get <int>(0));
            Assert.Equal(5, ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5).Get <int>("value"));

            // If nullable annotations are ignored and we request a nullable int, it should still work.
#nullable disable
예제 #2
0
        public void AccessValueByName()
        {
            var arguments = ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5);

            Assert.Equal(5, arguments.GetValue("value"));

            arguments.SetValue("value", 10);

            Assert.Equal(10, arguments.Get <int>("value"));
        }
예제 #3
0
        public void Count()
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
        => Assert.Equal(1, ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5).Count);
예제 #4
0
        public void AccessValueByIndex()
        {
            var arguments = ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5);

            Assert.Equal(5, arguments.GetValue(0));
        }
예제 #5
0
 public void ThrowsIfSetValueIndexNotFound()
 => Assert.Throws <IndexOutOfRangeException>(() => ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5).SetValue(42, 42));
예제 #6
0
 public void ThrowsIfSetValueNameNotFound()
 => Assert.Throws <KeyNotFoundException>(() => ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5).SetValue("foo", 42));
예제 #7
0
 public void ThrowsIfMismatchValuesLength()
 => Assert.Throws <TargetParameterCountException>(() => ArgumentCollection.Create(valueTypeMethod.GetParameters(), 5, "Foo"));