コード例 #1
0
        public void GetLongestString_GivenNegative_ThrowsInvalidArgumentException()
        {
            var ls = new LongestString();
            var invalidNthValue = -1;

            Assert.Throws <ArgumentException>(() => ls.GetNthLongestString(invalidNthValue, TestInputList));
        }
コード例 #2
0
        public void GetLongestString_ItemsWithNLengthInMultiplePositions_ReturnsItemClosestToHeadOfList(int positionOfStringThatHasPartnersOfSameLength, string expectedResult)
        {
            var ls           = new LongestString();
            var actualResult = ls.GetNthLongestString(positionOfStringThatHasPartnersOfSameLength, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #3
0
        public void GetShortestString_ListIsNull_ThrowsNullReferenceException()
        {
            var           ls             = new LongestString();
            List <string> aNullList      = null;
            var           aValidNthValue = 1;

            Assert.Throws <NullReferenceException>(() => ls.GetNthLongestString(aValidNthValue, aNullList));
        }
コード例 #4
0
        public void GetLongestString_ListIsEmpty_ThrowsInvalidArgumentException()
        {
            var ls             = new LongestString();
            var anEmptyList    = new List <string>();
            var aValidNthValue = 1;

            Assert.Throws <ArgumentException>(() => ls.GetNthLongestString(aValidNthValue, anEmptyList));
        }
コード例 #5
0
        public void GetLongestString_GivenNumberGreaterThanListLength_ReturnsShortestWord() {
            var ls = new LongestString();
            var positionGreaterThanListLength = 20;

            var expectedResult = "Cat";
            var actualResult = ls.GetNthLongestString(positionGreaterThanListLength, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #6
0
        public void GetLongestString_Normally_ReturnsTheLongestString() {
            var ls = new LongestString();
            var positionOfLongestString = 1;

            var expectedResult = "This code puzzle is easy";
            var actualResult = ls.GetNthLongestString(positionOfLongestString, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #7
0
        public void GetLongestString_Normally_ReturnsTheSpecifiedPosition()
        {
            var ls = new LongestString();
            var positionOfLongestString = 2;

            var expectedResult = "AVeryLongString";
            var actualResult = ls.GetNthLongestString(positionOfLongestString, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #8
0
        public void GetLongestString_GivenNumberGreaterThanListLength_ReturnsShortestWord()
        {
            var ls = new LongestString();
            var positionGreaterThanListLength = 20;

            var expectedResult = "Cat";
            var actualResult   = ls.GetNthLongestString(positionGreaterThanListLength, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #9
0
        public void GetLongestString_Normally_ReturnsTheSpecifiedPosition()
        {
            var ls = new LongestString();
            var positionOfLongestString = 2;

            var expectedResult = "AVeryLongString";
            var actualResult   = ls.GetNthLongestString(positionOfLongestString, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #10
0
        public void GetLongestString_Normally_ReturnsTheLongestString()
        {
            var ls = new LongestString();
            var positionOfLongestString = 1;

            var expectedResult = "This code puzzle is easy";
            var actualResult   = ls.GetNthLongestString(positionOfLongestString, TestInputList);

            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #11
0
 public void GetLongestString_ItemsWithNLengthInMultiplePositions_ReturnsItemClosestToHeadOfList(int positionOfStringThatHasPartnersOfSameLength, string expectedResult)
 {
     var ls = new LongestString();
     var actualResult = ls.GetNthLongestString(positionOfStringThatHasPartnersOfSameLength, TestInputList);
     Assert.AreEqual(expectedResult, actualResult);
 }
コード例 #12
0
 public void GetLongestString_GivenNegative_ThrowsInvalidArgumentException() {
     var ls = new LongestString();
     var invalidNthValue = -1;
     Assert.Throws<ArgumentException>(() => ls.GetNthLongestString(invalidNthValue, TestInputList));
 }
コード例 #13
0
 public void GetShortestString_ListIsNull_ThrowsNullReferenceException() {
     var ls = new LongestString();
     List<string> aNullList = null;
     var aValidNthValue = 1;
     Assert.Throws<NullReferenceException>(() => ls.GetNthLongestString(aValidNthValue, aNullList));
 }
コード例 #14
0
 public void GetLongestString_ListIsEmpty_ThrowsInvalidArgumentException() {
     var ls = new LongestString();
     var anEmptyList = new List<string>();
     var aValidNthValue = 1;
     Assert.Throws<ArgumentException>(() => ls.GetNthLongestString(aValidNthValue, anEmptyList));
 }