public void DecimalCounter_ArrayOfRangesIsNull_ThrowArgumentNullException()
 {
     // Act
     Assert.Throws <ArgumentNullException>(
         () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), null),
         message: "Method throws ArgumentNullException in case array of ranges is null.");
 }
 public void DecimalCounterWithStartIndexAndCount_ArrayToSearchIsNull_ThrowArgumentNullException()
 {
     // Act
     Assert.Throws <ArgumentNullException>(
         () => DecimalCounter.GetDecimalsCount(null, Array.Empty <decimal[]>(), 0, 1),
         message: "Method throws ArgumentNullException in case array to search is null.");
 }
        public void DecimalCounter_ArrayOfRangesIsEmpty_ReturnZeroOccurrences()
        {
            // Act
            int actual = DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFiveElements, Array.Empty <decimal[]>());

            // Assert
            Assert.AreEqual(0, actual);
        }
        public int DecimalCounter_FifteenElementsOneRange_ReturnsResult(int startIndex, int count)
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { -0.1m, 0.2m },
            };

            // Act
            return(DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFifteenElements, ranges, startIndex, count));
        }
        public int DecimalCounter_FiveElementsTwoRanges_ReturnsResult(int startIndex, int count)
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m, 0.5m },
            };

            // Act
            return(DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFiveElements, ranges, startIndex, count));
        }
        public void DecimalCounter_OneOfTheRangesIsInvalid_ThrowArgumentException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m,0.5m, 0.6m },
            };

            // Act
            Assert.Throws <ArgumentException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges),
                message: "Method throws ArgumentException in case the length of one of the ranges is less or greater than 2.");
        }
        public void DecimalCounter_OneOfTheRangesIsNull_ThrowArgumentNullException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                null,
            };

            // Act
            Assert.Throws <ArgumentNullException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges),
                message: "Method throws ArgumentNullException in case one of the ranges is null.");
        }
        public void DecimalCounterWithStartIndexAndCount_TheNumberOfElementsToSearchIsGreaterThanTheNumberOfElementsAvailableInTheArrayStartingFromTheStartIndexPosition_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m, 0.5m },
            };

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges, 4, 100000),
                message: "Method throws ArgumentOutOfRangeException in case the number of elements to search is greater than the number of elements available in the array starting from the startIndex position.");
        }
        public void DecimalCounter_ArrayToSearchIsEmpty_ReturnZeroOccurrences()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
            };

            // Act
            int actual = DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges);

            // Assert
            Assert.AreEqual(0, actual);
        }
        public void DecimalCounterWithStartIndexAndCount_CountIsLessThanZero_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m, 0.5m },
            };

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges, 4, -1),
                message: "Method throws ArgumentOutOfRangeException in case count is less than zero.");
        }
        public void DecimalCounterWithStartIndexAndCount_StartIndexIsGreaterThanTheLengthOfAnArrayToSearch_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m, 0.5m },
            };

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges, 1234, 1),
                message: "Method throws ArgumentOutOfRangeException in case start index is greater than the length of an array to search.");
        }
        public void DecimalCounterWithStartIndexAndCount_StartIndexIsNegative_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                new[] { 0.4m, 0.5m },
            };

            // Act
            Assert.Throws <ArgumentOutOfRangeException>(
                () => DecimalCounter.GetDecimalsCount(Array.Empty <decimal>(), ranges, -1234, 1),
                message: "Method throws ArgumentOutOfRangeException in case start index is negative.");
        }
        public void DecimalCounter_FifteenElementsOneRange_ReturnsResult()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { -0.1m, 0.2m },
            };

            // Act
            int actualResult = DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFifteenElements, ranges);

            // Assert
            Assert.AreEqual(4, actualResult);
        }
        public void DecimalCounter_OneOfTheRangesIsEmpty_ReturnValidResult()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] { 0.1m, 0.2m },
                Array.Empty <decimal>(),
            };

            // Act
            int actual = DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFiveElements, ranges);

            // Assert
            Assert.AreEqual(2, actual);
        }
        public void DecimalCounter_FifteenElementsThreeRanges_ReturnsResult()
        {
            // Arrange
            decimal[][] ranges =
            {
                new[] {        -0.1m,        0.2m },
                new[] {         0.4m,        0.5m },
                new[] { decimal.Zero, decimal.One },
            };

            // Act
            int actualResult = DecimalCounter.GetDecimalsCount(DecimalCounterTests.ArrayWithFifteenElements, ranges);

            // Assert
            Assert.AreEqual(8, actualResult);
        }