Example #1
0
        public void Get_IndexOutOfBounds(int[] input, string position)
        {
            // Arrange
            var resolver     = new DefaultContractResolver();
            var targetObject = new List <int>(input);
            var listAdapter  = new ListAdapter();

            // Act
            var getStatus = listAdapter.TryGet(targetObject, position, resolver, out var value, out var message);

            // Assert
            Assert.False(getStatus);
            Assert.Equal($"The index value provided by path segment '{position}' is out of bounds of the array size.", message);
        }
Example #2
0
        public void Get(int[] input, string position, object expected)
        {
            // Arrange
            var resolver     = new DefaultContractResolver();
            var targetObject = new List <int>(input);
            var listAdapter  = new ListAdapter();

            // Act
            var getStatus = listAdapter.TryGet(targetObject, position, resolver, out var value, out var message);

            // Assert
            Assert.True(getStatus);
            Assert.Equal(expected, value);
            Assert.Equal(new List <int>(input), targetObject);
        }
Example #3
0
        public void Get_IndexOutOfBounds(int[] input, string position)
        {
            // Arrange
            var resolver     = new Mock <IContractResolver>(MockBehavior.Strict);
            var targetObject = new List <int>(input);
            var listAdapter  = new ListAdapter();

            // Act
            var getStatus = listAdapter.TryGet(targetObject, position, resolver.Object, out var value, out var message);

            // Assert
            Assert.False(getStatus);
            Assert.Equal(
                string.Format("The index value provided by path segment '{0}' is out of bounds of the array size.", position),
                message);
        }