コード例 #1
0
                public void ShouldCorrectlyConflictWithTextAndOverwriteWhitespace()
                {
                    const string paperText    = "This is a sentence.";
                    const string editText     = "overwrite";
                    const string expectedText = "Thi@v@@w@i@@ntence.";
                    const int    startIndex   = 3;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #2
0
                public void ShouldSetNegativeStartIndexToZero()
                {
                    const string paperText    = "          ";
                    const string editText     = "Negative";
                    const string expectedText = "Negative  ";
                    const int    startIndex   = -20;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #3
0
                public void ShouldOverwriteBeyondExistingTextLength()
                {
                    const string paperText    = "          ";
                    const string editText     = "This is a sentence.";
                    const string expectedText = "     This is a sentence.";
                    const int    startIndex   = 5;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #4
0
                public void ShouldAppendToPaperWhenStartIndexIsTooLarge()
                {
                    const string paperText    = "This is a sentence.";
                    const string editText     = " This is another sentence.";
                    const string expectedText = "This is a sentence. This is another sentence.";
                    const int    startIndex   = 19;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #5
0
                public void ShouldOverwriteWhitespaceWithOtherWhitespace()
                {
                    const string paperText    = "               ";
                    const string editText     = " \t\r\n\f\v ";
                    const string expectedText = "    \t\r\n\f\v      ";
                    const int    startIndex   = 3;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #6
0
                public void ShouldNotOverwriteTextWithWhitespace()
                {
                    const string paperText    = "This is a sentence.";
                    const string editText     = " \t\r\n\f\v ";
                    const string expectedText = "This is a sentence.";
                    const int    startIndex   = 11;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #7
0
                public void ShouldOverwriteExistingTextWithConflictCharacter()
                {
                    const string paperText    = "This is a sentence.";
                    const string editText     = "Added";
                    const string expectedText = "This is a se@@@@@e.";
                    const int    startIndex   = 12;
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #8
0
                public void ShouldWriteWhitespaceIfNoDurability()
                {
                    const string paperText       = "Word       Word";
                    const string editText        = "a\t\r\n\f\va";
                    const string expectedText    = "Word \t\r\n\f\v Word";
                    const int    startIndex      = 4;
                    const int    pointDurability = 0;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #9
0
                public void ShouldAddSpacesBeyondExistingTextLengthIfBecomesDull()
                {
                    const string paperText       = "          ";
                    const string editText        = "This is a sentence.";
                    const string expectedText    = "     This is a          ";
                    const int    startIndex      = 5;
                    const int    pointDurability = 8;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #10
0
                public void ShouldNotWriteUppercaseIfNotEnoughDurability()
                {
                    const string paperText       = "Word     Word";
                    const string editText        = "tTt";
                    const string expectedText    = "Word t t Word";
                    const int    startindex      = 5;
                    const int    pointDurability = 2;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper(paperText);

                    pencil.Edit(paper, editText, startindex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #11
0
                public void ShouldWritePartialEditWhenDurabilityRunsOut()
                {
                    const string paperText       = "This is a sentence.";
                    const string editText        = "overwrite";
                    const string expectedText    = "Thi@v@@wa sentence.";
                    const int    startIndex      = 3;
                    const int    pointDurability = 5;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedText, paper.Text);
                }
コード例 #12
0
                public void ShouldCorrectlyDegradeWhenOverwritingText()
                {
                    const string paperText               = "This is a sentence.";
                    const string editText                = "overwrite";
                    const int    startIndex              = 3;
                    const int    startPointDurability    = 129;
                    const int    expectedPointDurability = 120;
                    IPencil      pencil = GetPencil(pointDurability: startPointDurability);
                    IPaper       paper  = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
コード例 #13
0
                public void ShouldCorrectlyDegradeWhenAppendedToTheEnd()
                {
                    const string paperText               = "This is a sentence.";
                    const string editText                = " This is another sentence.";
                    const int    startIndex              = 19;
                    const int    startPointDurability    = 123;
                    const int    expectedPointDurability = 100;
                    IPencil      pencil = GetPencil(pointDurability: startPointDurability);
                    IPaper       paper  = GetPaper(paperText);

                    pencil.Edit(paper, editText, startIndex);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }