public void ReverseWordsMethodMustTreatWordsSeparatedByWhiteSpaceAsSeparatedWords()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("test rest");

            Assert.Equal("tset tser", result);
        }
        public void ReverseWordsMethodsMustReverseWordsContainingSpecialCharacters()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("P()|-3|\\/|@000|\\|$");

            Assert.Equal("$|\\|000@|/\\|3-|)(P", result);
        }
        public void ReverseWordsMethodMustReturnIdenticalWhenInputIsSingleWordPalindrome()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("saas");

            Assert.Equal("saas", result);
        }
        public void ReverseWordsMethodMustTreatWordsSeparatedByAnyCharDelimetersAsSingleWord()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("test,rest.west;vest");

            Assert.Equal("tsev;tsew.tser,tset", result);
        }
        public void ReverseWordsMethodsMustReverseEscapeSequences()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("\\n\\t\\r");

            Assert.Equal("r\\t\\n\\", result);
        }
        public void ReverseWordsMethodMustReverseVeryLongInput()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("imaverylongwordsoyoushouldbecarefulreversingme!");

            Assert.Equal("!emgnisreverluferacebdluohsuoyosdrowgnolyrevami", result);
        }
        public void ReverseWordsMethodMustReverseInputWhenSingleWordWithoutWhiteSpacesIsProvided()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("test");

            Assert.Equal("tset", result);
        }
        public void ReverseWordsMethodMustTreatNullStringAsEmpty()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords(null);

            Assert.Equal(string.Empty, result);
        }
        public void ReverseWordsMethodMustNotRemoveAnySpaces()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords("  test     rest            VEST      ");

            Assert.Equal("  tset     tser            TSEV      ", result);
        }
        public void ReverseWordsMethodMustReturnEmptyStringWhenInputIsEmpty()
        {
            var mockedMemoryCacheWrapper = new Mock <IMemoryCacheWrapper>();
            var reverseWordsService      = new ReverseWordsService(mockedMemoryCacheWrapper.Object);

            var result = reverseWordsService.ReverseWords(string.Empty);

            Assert.Equal(string.Empty, result);
        }
Ejemplo n.º 11
0
        public void ReverseWords_InvalidStringLength_MaxLengthException()
        {
            var reverseService = new ReverseWordsService();

            var inputStr = new string(new char[int.MaxValue / 21]);

            Exception exception = null;

            try
            {
                reverseService.ReverseWords(inputStr);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is MaxLengthException);
                exception = ex;
            }
            Assert.IsNotNull(exception);
        }