コード例 #1
0
                public void ShouldReplaceMatchingTextWithCorrectAmountOfSpaces(string testWord, string expected)
                {
                    IPencil pencil = GetPencil();
                    IPaper  paper  = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.Equal(expected, paper.Text);
                }
コード例 #2
0
                public void ShouldNeverBecomeNegative(string sentence, int startEraserDurability)
                {
                    const int expectedEraserDurability = 0;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(sentence);

                    pencil.Erase(paper, sentence);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
コード例 #3
0
                public void ShouldRemoveMatchingText()
                {
                    const string testWord = "word";
                    IPencil      pencil   = GetPencil();
                    IPaper       paper    = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.DoesNotContain(testWord, paper.Text);
                }
コード例 #4
0
                public void ShouldDegradeCorrectlyForManyCharacters(string eraseMatch)
                {
                    const int startEraserDurability    = 50;
                    int       expectedEraserDurability = startEraserDurability - eraseMatch.Length;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(eraseMatch);

                    pencil.Erase(paper, eraseMatch);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
コード例 #5
0
                public void ShouldDoNothingWithNoDurability()
                {
                    const string testSentence     = "  \v0?>9\n<8:6 (*4&\t^2# 1$%  ";
                    const int    eraserDurability = 0;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(testSentence);

                    pencil.Erase(paper, testSentence);

                    Assert.Equal(testSentence, paper.Text);
                }
コード例 #6
0
                public void ShouldReplaceWhitespaceWithSpaces()
                {
                    const string testWhitespace = "  \t\r\n\f\v  ";
                    const string expected       = "         ";
                    IPencil      pencil         = GetPencil();
                    IPaper       paper          = GetPaper(testWhitespace);

                    pencil.Erase(paper, testWhitespace);

                    Assert.Equal(expected, paper.Text);
                }
コード例 #7
0
                public void ShouldDegradeCorrectlyForMixedCharactersAndWhitespace(string mixedString, int degradeAmount)
                {
                    const int startEraserDurability    = 50;
                    int       expectedEraserDurability = startEraserDurability - degradeAmount;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(mixedString);

                    pencil.Erase(paper, mixedString);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
コード例 #8
0
                public void ShouldDoNothingIfNoMatchIsFound()
                {
                    const string testSentence = "Not this or this";
                    const string eraseWord    = "test";
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(testSentence);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(testSentence, paper.Text);
                }
コード例 #9
0
                public void ShouldErasePartOfMatchingWord()
                {
                    const string testWord         = "word";
                    const string expectedWord     = "wo  ";
                    const int    eraserDurability = 2;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.Equal(expectedWord, paper.Text);
                }
コード例 #10
0
                public void ShouldReplaceOnlyMatchingText()
                {
                    const string paperText        = "this is a test sentence";
                    const string eraseWord        = "test";
                    const string expectedSentence = "this is a      sentence";
                    IPencil      pencil           = GetPencil();
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #11
0
                public void ShouldMatchOnCaseWhenMatching()
                {
                    const string paperText        = "This but not this";
                    const string eraseWord        = "This";
                    const string expectedSentence = "     but not this";
                    IPencil      pencil           = GetPencil();
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #12
0
                public void ShouldOnlyReplaceTheLastMatch()
                {
                    const string paperText        = "Not this but this";
                    const string eraseWord        = "this";
                    const string expectedSentence = "Not this but     ";
                    IPencil      pencil           = GetPencil();
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #13
0
                public void ShouldNotEraseMatchingWhitespaceWhenDurabilityRunsOut()
                {
                    const string paperText        = "This\n\n\nis a sentence.";
                    const string eraseMatch       = "\n\n\nis a";
                    const string expectedSentence = "This\n\n\n     sentence.";
                    const int    eraserDurability = 3;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseMatch);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #14
0
                public void ShouldEraseCorrectPartialMatch()
                {
                    const string paperText        = "things running";
                    const string eraseWord        = "thing";
                    const string expectedSentence = "th   s running";
                    const int    eraserDurability = 3;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #15
0
                public void ShouldEraseCorrectPartOfMatchThatIncludesWhitespace()
                {
                    const string paperText        = "This is a test sentence.";
                    const string eraseSection     = "is a test";
                    const string expectedSentence = "This i         sentence.";
                    const int    eraserDurability = 6;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseSection);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #16
0
                public void ShouldErasePartOfMatchingWordInSentence()
                {
                    const string paperText        = "This is a word in a sentence.";
                    const string testWord         = "word";
                    const string expectedSentence = "This is a wo   in a sentence.";
                    const int    eraserDurability = 2;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, testWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }
コード例 #17
0
                public void ShouldDegradeByOneWhenErasingOneCharacter()
                {
                    const string paperText                = "This is a sentence";
                    const string eraseLetter              = "a";
                    const int    startEraserDurability    = 5;
                    const int    expectedEraserDurability = 4;
                    IPencil      pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper       paper  = GetPaper(paperText);

                    pencil.Erase(paper, eraseLetter);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }