public void GetElementNameBytes_should_return_new_byte_array_when_not_cached(int numberOfCachedElementNames)
        {
            var subject = new ArrayElementNameAccelerator(numberOfCachedElementNames);
            var index = numberOfCachedElementNames;

            var result1 = subject.GetElementNameBytes(index);
            var result2 = subject.GetElementNameBytes(index);

            Assert.NotSame(result1, result2);
        }
        public void GetElementNameBytes_should_return_same_byte_array_when_cached(int numberOfCachedElementNames)
        {
            var subject = new ArrayElementNameAccelerator(numberOfCachedElementNames);

            for (var index = 0; index < numberOfCachedElementNames; index++)
            {
                var result1 = subject.GetElementNameBytes(index);
                var result2 = subject.GetElementNameBytes(index);

                Assert.Same(result1, result2);
            }
        }
        public void GetElementNameBytes_should_return_expected_result(int numberOfCachedElementNames)
        {
            var subject = new ArrayElementNameAccelerator(numberOfCachedElementNames);

            for (var index = 0; index < numberOfCachedElementNames + 10; index++)
            {
                var result = subject.GetElementNameBytes(index);

                var expectedResult = Utf8Encodings.Strict.GetBytes(index.ToString());
                Assert.Equal(expectedResult, result);
            }
        }
        public void GetElementNameBytes_should_return_expected_result_for_boundary_conditions(
            [Values(0, 9, 10, 99, 100, 999, 1000, 9999, 10000, 99999, 100000, 999999, 1000000, 9999999, 100000000, int.MaxValue)]
            int index,
            [Values(0)]
            int numberOfCachedElementNames)
        {
            var subject = new ArrayElementNameAccelerator(numberOfCachedElementNames);

            var result = subject.GetElementNameBytes(index);

            var expectedResult = Utf8Encodings.Strict.GetBytes(index.ToString());
            Assert.Equal(expectedResult, result);
        }
        public void GetElementNameBytes_should_throw_when_index_is_negative()
        {
            var subject = new ArrayElementNameAccelerator(0);

            Assert.Throws<ArgumentOutOfRangeException>(() => subject.GetElementNameBytes(-1));
        }