Esempio n. 1
0
 public void GetIntegersCountWithStartIndexAndCount_ArrayToSearchIsNull_ThrowArgumentNullException()
 {
     // Act
     Assert.Throws <ArgumentNullException>(
         () => IntegersCounter.GetIntegersCount(null, Array.Empty <int>(), 0, 1),
         message: "Method throws ArgumentNullException in case an array to search is null.");
 }
Esempio n. 2
0
 public void GetIntegersCountWithStartIndexAndCount_StartIndexIsNegative_ThrowArgumentOutOfRangeException()
 {
     // Act
     Assert.Throws <ArgumentOutOfRangeException>(
         () => IntegersCounter.GetIntegersCount(Array.Empty <int>(), Array.Empty <int>(), -1, 1),
         message: "Method throws ArgumentOutOfRangeException in case start index is negative.");
 }
Esempio n. 3
0
 public void GetIntegersCountWithStartIndexAndCount_ElementsToSearchForIsNull_ThrowArgumentNullException()
 {
     // Act
     Assert.Throws <ArgumentNullException>(
         () => IntegersCounter.GetIntegersCount(Array.Empty <int>(), null, 0, 1),
         message: "Method throws ArgumentNullException in case an array of elements to for search is null.");
 }
Esempio n. 4
0
 public void GetIntegersCountWithStartIndexAndCount_TheNumberOfElementsToSearchIsGreaterThanTheNumberOfElementsAvailableInTheArrayStartingFromTheStartIndexPosition_ThrowArgumentOutOfRangeException()
 {
     // Act
     Assert.Throws <ArgumentOutOfRangeException>(
         () => IntegersCounter.GetIntegersCount(Array.Empty <int>(), Array.Empty <int>(), 6, 44),
         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.");
 }
Esempio n. 5
0
 public void GetIntegersCountWithStartIndexAndCount_CountIsLessThanZero_ReturnValidResult()
 {
     // Act
     Assert.Throws <ArgumentOutOfRangeException>(
         () => IntegersCounter.GetIntegersCount(Array.Empty <int>(), Array.Empty <int>(), 2, -1),
         message: "Method throws ArgumentOutOfRangeException in case count is less than zero.");
 }
Esempio n. 6
0
 public void GetIntegersCountWithStartIndexAndCount_StartIndexIsGreaterThanTheLengthOfAnArrayToSearch_ThrowArgumentOutOfRangeException()
 {
     // Act
     Assert.Throws <ArgumentOutOfRangeException>(
         () => IntegersCounter.GetIntegersCount(Array.Empty <int>(), Array.Empty <int>(), 12, 1),
         message: "Method throws ArgumentOutOfRangeException in case start index is greater than the length of an array to search.");
 }
Esempio n. 7
0
        public void GetIntegersCountWithStartIndexAndCount_ElementsToSearchForIsEmpty_ReturnZeroOccurrences()
        {
            // Arrange
            int[] arrayToSearch = { 2, 5, 8 };

            // Act
            int actual = IntegersCounter.GetIntegersCount(arrayToSearch, Array.Empty <int>(), 0, 1);

            // Assert
            Assert.AreEqual(0, actual);
        }
Esempio n. 8
0
        public void GetIntegersCount_ArrayToSearchIsEmpty_ReturnZeroOccurrences()
        {
            // Arrange
            int[] elementsToSearchFor = { 2, 5, 8 };

            // Act
            int actual = IntegersCounter.GetIntegersCount(Array.Empty <int>(), elementsToSearchFor);

            // Assert
            Assert.AreEqual(0, actual);
        }
Esempio n. 9
0
 public int GetIntegersCount_ParametersAreValid_ReturnsResult(int[] arrayToSearch, int[] elementsToSearchFor)
 {
     // Act
     return(IntegersCounter.GetIntegersCount(arrayToSearch, elementsToSearchFor));
 }