public void ReturnTheWholeInputString_WhenThePassedCountIsGreaterThanInputStringLength() { string validInputString = "Valid"; int validCount = 10; string expected = "Valid"; string result = ExceptionsHomework.ExtractEnding(validInputString, validCount); Assert.AreEqual(expected, result); }
public void ThrowArgumentException_WhenThePassedCollectionIsNull() { // Arrange int validStartIndex = 0; int validCount = 2; // Act and Assert Assert.Throws <ArgumentException>( () => ExceptionsHomework.Subsequence <int>(null, validStartIndex, validCount)); }
public void ReturnNewSubstringConsistingOfCountNumberOfCharactersFromTheEnding_WhenThePassedParametersAreValid() { string validInputString = "Valid input string"; int validCount = 6; string expected = "string"; string result = ExceptionsHomework.ExtractEnding(validInputString, validCount); Assert.AreEqual(expected, result); }
public void ReturnEmptyString_WhenThePassedCountIsNegative() { string validInputString = "Valid input string"; int validCount = -1; string expected = string.Empty; string result = ExceptionsHomework.ExtractEnding(validInputString, validCount); Assert.AreEqual(expected, result); }
public void ThrowArgumentException_WhenThePassedCountIsGreaterThanTheCollectionLength() { // Arrange int validStartIndex = 0; int greaterCount = 10; int[] validCollection = new int[4]; // Act and Assert Assert.Throws <ArgumentException>( () => ExceptionsHomework.Subsequence <int>(validCollection, validStartIndex, greaterCount)); }
public void ThrowArgumentException_WhenThePassedCountIsNegative() { // Arrange int validStartIndex = 0; int negativeCount = -1; int[] validCollection = new int[4]; // Act and Assert Assert.Throws <ArgumentException>( () => ExceptionsHomework.Subsequence <int>(validCollection, validStartIndex, negativeCount)); }
public void ThrowArgumentException_WhenThePassedCollectionHasNoElements() { // Arrange int validStartIndex = 0; int validCount = 2; int[] arrayWithoutElements = new int[0]; // Act and Assert Assert.Throws <ArgumentException>( () => ExceptionsHomework.Subsequence <int>(arrayWithoutElements, validStartIndex, validCount)); }
public void ReturnElementsFromStartIndexToEndOfCollection_WhenTheSumOfThePassedStartIndexAndCountIsGreaterThanTheCollectionLength() { // Arrange int validStartIndex = 2; int validCount = 3; int[] validCollection = new int[] { 1, 2, 3, 4 }; int[] expectedCollection = new int[] { 3, 4 }; // Act var result = ExceptionsHomework.Subsequence <int>(validCollection, validStartIndex, validCount); // Assert Assert.AreEqual(expectedCollection, result); }
public void ReturnNewCollection_WhenAllPassedParametersAreValid() { // Arrange int validStartIndex = 0; int validCount = 4; int[] validCollection = new int[] { 1, 2, 3, 4 }; int[] expectedCollection = new int[] { 1, 2, 3, 4 }; // Act var result = ExceptionsHomework.Subsequence <int>(validCollection, validStartIndex, validCount); // Assert Assert.AreNotSame(expectedCollection, result); }
public void ReturnNewCollectionWhichIsCountElementsSubsequenceFromStartIndex_WhenAllPassedParametersAreValid() { // Arrange int validStartIndex = 0; int validCount = 3; int[] validCollection = new int[] { 1, 2, 3, 4 }; int[] expectedCollection = new int[] { 1, 2, 3 }; // Act var result = ExceptionsHomework.Subsequence <int>(validCollection, validStartIndex, validCount); // Assert Assert.AreEqual(expectedCollection, result); }
public void ThrowArgumentException_WhenThePassedStringIsNullOrWhitespace(string inputString) { int validCount = 1; Assert.Throws <ArgumentException>(() => ExceptionsHomework.ExtractEnding(inputString, validCount)); }
public void ReturnFalse_WhenThePassedNumberIsNotPrime(int nonprimeNumber) { bool isPrime = ExceptionsHomework.CheckPrime(nonprimeNumber); Assert.IsFalse(isPrime); }
public void ReturnTrue_WhenThePassedNumberIsPrime(int primeNumber) { bool isPrime = ExceptionsHomework.CheckPrime(primeNumber); Assert.IsTrue(isPrime); }
public void NotThrow_WhenThePassedNumberIsValid(int validNumber) { Assert.DoesNotThrow(() => ExceptionsHomework.CheckPrime(validNumber)); }
public void ThrowArgumentException_WhenThePassedNumberIsSmallerThanTwo(int invalidNumber) { Assert.Throws <ArgumentException>(() => ExceptionsHomework.CheckPrime(invalidNumber)); }