Beispiel #1
0
        public void TestEditAddsToFirstBlankSpaceOnPaper()
        {
            // Act
            paper.Text += pencil.Write(testSentenceWithSpace);
            paper.Text  = pencil.Edit("test", paper.Text);

            // Assert
            Assert.AreEqual(genericTestSentence, paper.Text, "Test sentence should match paper text, edit should add word to first blank area in sentence");
        }
Beispiel #2
0
        public void WhenEditingIfPointDurabilityIsExhaustedPencilWritesWhitespaces()
        {
            Pencil pencil = new Pencil(3, 10, 10);
            String paper  = pencil.Erase("Mary had a little lamb", "had a");

            Assert.Equal("Mary kic   little lamb", pencil.Edit(paper, "kicked", pencil.EditIndex));
        }
Beispiel #3
0
        public void WhenEditingPencilDurabilityIsImpactedByCharacterCase()
        {
            Pencil pencil = new Pencil(4, 10, 10);
            String paper  = pencil.Erase("Mary had a little lamb", "Mary had");

            Assert.Equal("Joh      a little lamb", pencil.Edit(paper, "John", pencil.EditIndex));
        }
Beispiel #4
0
        public void EditCannotOccurIfEraseHasNotFirstOccurred()
        {
            Pencil pencil = new Pencil(5, 5, 5);
            String paper  = "Mary had a little lamb";

            Assert.Equal(paper, pencil.Edit(paper, "wolf", pencil.EditIndex));
        }
Beispiel #5
0
        public void EditOccursAtLastEditIndexSetWhenEraseHasBeenCalledMultipleTimes()
        {
            Pencil pencil = new Pencil(5, 10, 10);
            String paper  = pencil.Erase("Mary had a little lamb", "had");

            paper = pencil.Erase(paper, "lamb");
            Assert.Equal("Mary     a little goat", pencil.Edit(paper, "goat", pencil.EditIndex));
        }
Beispiel #6
0
        public void WhenEditPassedNewTextInsertsThatText()
        {
            Pencil pencil = new Pencil(5, 20, 20, "An apple a day");

            pencil.Erase("apple");
            string word = "onion";

            pencil.Edit(word);
            Assert.AreEqual("An onion a day", pencil.Paper);
        }
Beispiel #7
0
        public void WhenEditingAndTheNewTextIsLongerThanTheWhitespaceThenTheCharacterCollisionsAreReplacedWithASymbol()
        {
            var pencil = new Pencil(250, 3, 20);

            pencil.Write("An apple a day keeps the doctor away");
            pencil.Erase("apple");
            pencil.Edit("artichoke");

            Assert.AreEqual("An artich@k@ay keeps the doctor away", pencil.Paper);
        }
Beispiel #8
0
        public void WhenThePencilEditsItReplacesSpacesWithTheNewText()
        {
            var pencil = new Pencil(250, 3, 20);

            pencil.Write("An apple a day keeps the doctor away");
            pencil.Erase("apple");
            pencil.Edit("onion");

            Assert.AreEqual("An onion a day keeps the doctor away", pencil.Paper);
        }
Beispiel #9
0
        public void When_Edit_Expect_PaperToHaveEditTextCalledWithGivenEditText()
        {
            var editText = "edit";

            var pencil = new Pencil(paperMock.Object, 100, 5, 100);

            pencil.Edit(editText);

            paperMock.Verify(_paper => _paper.EditText(It.Is <string>(p => p == editText)), Times.Once);
        }
Beispiel #10
0
        public void WhenEditPassedStringThatCollidesWithExistingTextCollsionsReplacedWithAtSymbol()
        {
            Pencil pencil = new Pencil(5, 20, 20, "An apple a day");

            pencil.Erase("apple");
            string newText = "artichoke";

            pencil.Edit(newText);
            Assert.AreEqual("An artich@k@ay", pencil.Paper);
        }
Beispiel #11
0
        public void WhenEditPassedTextWithTwoCollisionsOneUpperCaseSixLowerCaseCharsPointDurabilityDecreasesByTen()
        {
            Pencil pencil = new Pencil(5, 20, 20, "An apple a day");

            pencil.Erase("apple");
            string newText = "ArtichOke";

            pencil.Edit(newText);
            Assert.AreEqual(10, pencil.PointDurability);
        }
Beispiel #12
0
        public void WhenEditPassedStringLongerThanPaperAppendsExcessCharsToPaper()
        {
            Pencil pencil = new Pencil(5, 20, 20, "Buffalo Bill");

            pencil.Erase("Bill");
            string newText = ("William");

            pencil.Edit(newText);
            Assert.AreEqual("Buffalo William", pencil.Paper);
        }
Beispiel #13
0
        public void Edit_Test()
        {
            Pencil _pencil = new Pencil(4000, 1000, 300);

            _pencil.Write("An onion a day keeps the doctor away");

            _pencil.Erase("onion");

            _pencil.Edit("artichoke");
            Assert.AreEqual("An artich@k@ay keeps the doctor away", _pencil.FullText);
        }
Beispiel #14
0
        public void WhenEditMethodCalledAddsCharsAtIndexWithoutCollision()
        {
            Pencil pencil = new Pencil(500, 5);
            Paper  paper  = new Paper();
            Eraser eraser = new Eraser(20);

            pencil.Write("Hello World", paper);
            eraser.Erase("World", paper);
            pencil.Edit("Howdy", paper);

            Assert.AreEqual("Hello Howdy", paper.Text);
        }
Beispiel #15
0
        public void WhenEditMethodCalledIfOverwriteCharIsSpaceDoNotReplaceOriginalChar()
        {
            Pencil pencil = new Pencil(500, 5);
            Paper  paper  = new Paper();
            Eraser eraser = new Eraser(20);

            pencil.Write("Hello World", paper);
            eraser.Erase("Wor", paper);
            pencil.Edit("hey u", paper);

            Assert.AreEqual("Hello heyl@", paper.Text);
        }
Beispiel #16
0
        public void WhenEditMethodCalledIfCharsCollideExistingCharOverwrittenWithSpecialChar()
        {
            Pencil pencil = new Pencil(500, 5);
            Paper  paper  = new Paper();
            Eraser eraser = new Eraser(20);

            pencil.Write("Hello World", paper);
            eraser.Erase("lo", paper);
            pencil.Edit("Howdy", paper);

            Assert.AreEqual("HelHow@@rld", paper.Text);
        }
Beispiel #17
0
        public void EditShouldReplaceErasedText()
        {
            string inputText    = "An apple a day keeps the doctor away";
            string expectedText = "An onion a day keeps the doctor away";
            string actualText;

            Pencil pencil = new Pencil(20, 20, 20);

            pencil.Written = inputText;
            pencil.Edit("apple", "onion");
            actualText = pencil.Written;

            Assert.AreEqual(expectedText, actualText);
        }
Beispiel #18
0
        public void EditShouldKeepSpacesIfReplacementIsTooShort()
        {
            string inputText    = "An apple a day keeps the doctor away";
            string expectedText = "An owl   a day keeps the doctor away";
            string actualText;

            Pencil pencil = new Pencil(20, 20, 20);

            pencil.Written = inputText;
            pencil.Edit("apple", "owl");
            actualText = pencil.Written;

            Assert.AreEqual(expectedText, actualText);
        }
Beispiel #19
0
        public void EditShouldReplaceErasedTextWithSymbolIfTooLong()
        {
            string inputText    = "An apple a day keeps the doctor away";
            string expectedText = "An artich@k@ay keeps the doctor away";
            string actualText;

            Pencil pencil = new Pencil(20, 20, 20);

            pencil.Written = inputText;
            pencil.Edit("apple", "artichoke");
            actualText = pencil.Written;

            Assert.AreEqual(expectedText, actualText);
        }
 public void EditsInsertTextIntoWhitespaceFromLastDelete()
 {
     Assert.Equal("Lorem quinc dolor sit amet", pencil.Edit("quinc"));
 }
Beispiel #21
0
        public void EditCanReplaceErasedWordWithANewWord()
        {
            String paper = pencil.Erase("Mary had a little lamb", "lamb");

            Assert.Equal("Mary had a little bird", pencil.Edit(paper, "bird", pencil.EditIndex));
        }
Beispiel #22
0
 public void PencilEditMethodReceivesErasedStringFromEraseMethodWhenItIsCalledTest()
 {
     paper.Text = "This is a test string";
     Assert.AreEqual("This is a      string", pencil.Edit(paper, "test", "    "));
 }