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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }