コード例 #1
0
        public void SingleNextTest()
        {
            IStringMutator sut            = new ToUpperMutator();
            IStringMutator stringMutator2 = new InvertMutator();
            IStringMutator stringMutator3 = new RemoveNumbersMutator();
            IStringMutator stringMutator4 = new TrimMutator();

            sut.SetNext(stringMutator2);
            sut.SetNext(stringMutator3);
            sut.SetNext(stringMutator4);

            string actual = sut.Mutate("    some2345Text        ");

            Assert.Equal("SOME2345TEXT", actual);
        }
コード例 #2
0
        public void StringMutatorsTest()
        {
            IStringMutator stringMutator1 = new ToUpperMutator();
            IStringMutator stringMutator2 = new InvertMutator();
            IStringMutator stringMutator3 = new RemoveNumbersMutator();
            IStringMutator stringMutator4 = new TrimMutator();

            stringMutator1
            .SetNext(stringMutator2)
            .SetNext(stringMutator3)
            .SetNext(stringMutator4);

            string actual = stringMutator1.Mutate("    SOME 1 input 2 String 3");

            Assert.Equal("GNIRTS  TUPNI  EMOS", actual);
        }
コード例 #3
0
        public void NullHandlingTest()
        {
            IStringMutator stringMutator = new ToUpperMutator();
            var            result        = stringMutator.Mutate(null);

            Assert.Null(result);

            stringMutator = new InvertMutator();
            result        = stringMutator.Mutate(null);
            Assert.Null(result);

            stringMutator = new RemoveNumbersMutator();
            result        = stringMutator.Mutate(null);
            Assert.Null(result);

            stringMutator = new TrimMutator();
            result        = stringMutator.Mutate(null);
            Assert.Null(result);
        }