Exemple #1
0
        public void GivenIHaveABigArray_WhenIGetANegativeIndex_AnExceptionIsThrow()
        {
            Action action = () =>
            {
                using (var noLohArray = new NoLohArray <double>(10))
                {
                    var value = noLohArray[-1];
                }
            };

            action.ShouldThrow <ArgumentException>();
        }
Exemple #2
0
        public void GivenIHaveABigArray_WhenIGetAnIndexGreaterThanLength_AnExceptionIsThrow()
        {
            Action action = () =>
            {
                using (var noLohArray = new NoLohArray <double>(10))
                {
                    var value = noLohArray[10];
                }
            };

            action.ShouldThrow <ArgumentException>();
        }
Exemple #3
0
        public void GivenIHaveTheLengthOfABigArray_WhenICreateABigArrayTest_AnInstanceIsCreated(int length, int filledIndex)
        {
            var random       = new Random();
            var filledValues = new Dictionary <int, double>();

            for (int i = 0; i < filledIndex; i++)
            {
                filledValues[random.Next(length - 1)] = random.NextDouble();
            }

            using (var array = new NoLohArray <double>(length, true))
            {
                foreach (var item in filledValues)
                {
                    array[item.Key] = item.Value;
                }

                foreach (var item in filledValues)
                {
                    array[item.Key].Should().Be(item.Value);
                }
            }
        }