public void WhenAPencilErasesTextItReplacesTextWithWhiteSpace()
        {
            paper.AddContent("Now You See Me");
            pencil.Erase(paper, "See");

            Assert.IsTrue(!paper.content.Contains("See"));
        }
 public void PencilEditMethodDoesNotAlterPaperTextPropertyWhenRemainingEraserIsZeroTest()
 {
     paper.Text             = "test";
     pencil.RemainingEraser = 0;
     pencil.Erase(paper, "test", out int startIndex);
     Assert.AreEqual("test", paper.Text);
 }
Example #3
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));
        }
Example #4
0
        public void WhenErasingTwiceTheLastTwoWordsAreRemoved()
        {
            var pencil = new Pencil();
            var paper  = new Paper();

            pencil.Write(ErasingTestText, ref paper);
            pencil.Erase("chuck", ref paper);
            pencil.Erase("chuck", ref paper);

            Assert.Equal(paper.Content, "How much wood would a woodchuck chuck if a wood      could       wood?");
        }
Example #5
0
        public void WhenAPencilErasesTextTwiceTheLastTwoOccurrencesAreReplacedWithSpaces()
        {
            var pencil = new Pencil(250, 3, 200);

            pencil.Write("How much wood would a woodchuck chuck if a woodchuck could chuck wood?");

            pencil.Erase("chuck");
            pencil.Erase("chuck");

            Assert.AreEqual("How much wood would a woodchuck chuck if a wood      could       wood?",
                            pencil.Paper);
        }
Example #6
0
        public void WhenErasingTheEraserStopsWorkingWhenCompletelyDegradedWithMultipleErases()
        {
            var pencil = new Pencil(1000, 5, 10);
            var paper  = new Paper();

            pencil.Write(ErasingTestText, ref paper);

            pencil.Erase("wood", ref paper);
            pencil.Erase("wood", ref paper);
            pencil.Erase("wood", ref paper);

            Assert.Equal("How much wood would a wo  chuck chuck if a     chuck could chuck     ?", paper.Content);
        }
Example #7
0
        public void WhenErasePassedStringofTwoCharsEraserDurabilityDecreasesByTwo()
        {
            Pencil pencil = new Pencil(5, 20, 20, "ab");

            pencil.Erase("ab");
            Assert.AreEqual(18, pencil.EraserDurability);
        }
Example #8
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));
        }
Example #9
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));
        }
Example #10
0
        public void WhenAPencilHasInsufficientEraserDurabilityItErasesAsManyCharactersAsItHasDurability()
        {
            Pencil pencil = new Pencil(10, 5, 5);
            String paper  = "Mary had a little lamb";

            Assert.Equal("Mary had a l      lamb", pencil.Erase(paper, "little"));
        }
Example #11
0
        public void AfterErasingPartialWordWordTheEditIndexPropertyIsSetTwo()
        {
            Pencil pencil = new Pencil(10, 10, 3);
            String paper  = pencil.Erase("Mary had a little lamb", "Mary");

            Assert.Equal(1, pencil.EditIndex);
        }
Example #12
0
        public void AfterErasingEntireWordTheEditIndexPropertyIsSet()
        {
            Pencil pencil = new Pencil(5, 5, 5);
            String paper  = pencil.Erase("Mary had a little lamb", "lamb");

            Assert.Equal(18, pencil.EditIndex);
        }
Example #13
0
        public void WhenErasePassedTextToEraseWithTwoInstancesofSameWordRemovesLastInstanceOfWordFromString()
        {
            Pencil pencil = new Pencil(5, 30, 30, "how much wood can a woodchuck");

            pencil.Erase("wood");
            Assert.AreEqual("how much wood can a     chuck", pencil.Paper);
        }
Example #14
0
        public void AfterErasingWholePhraseWithWhitespacesTheEditIndexPropertyIsSet()
        {
            Pencil pencil = new Pencil(20, 20, 10);
            String paper  = pencil.Erase("Mary had a little lamb", "had a little");

            Assert.Equal(5, pencil.EditIndex);
        }
Example #15
0
        public void WhenErasePassedStringItErasesOppositeOrderStringWasWrittenAndReplacesWithWhiteSpace()
        {
            Pencil pencil = new Pencil(5, 20, 1, "Bill");

            pencil.Erase("Bill");
            Assert.AreEqual("Bil ", pencil.Paper);
        }
Example #16
0
        public void WhenPencilEraserIsZeroAndItErases_PaperTextIsUnchanged()
        {
            pencil = new Pencil(defaultDurability, defaultLength, 0);
            sheet  = new Paper("Nothing ever changes");

            pencil.Erase("changes", sheet);
            Assert.AreEqual("Nothing ever changes", sheet.Text);
        }
Example #17
0
        public void WhenAPencilErasesRepeatedTextInASingleWordEraseTheLastOccurance()
        {
            pencil = new Pencil(100, 8, 5);
            paper.AddContent("BamBam");
            pencil.Erase(paper, "Bam");

            Assert.AreEqual("Bam   ", paper.content);
        }
Example #18
0
        public void WhenErasePassedWhiteSpaceEraserDurabilityIsNotAffectedByWhiteSpace()
        {
            Pencil pencil      = new Pencil(5, 20, 20, "test  test");
            string textToErase = "  ";

            pencil.Erase(textToErase);
            Assert.AreEqual(18, pencil.EraserDurability);
        }
Example #19
0
        public void WhenErasePassedOneCharEraserDurabilityDecreasesByOne()
        {
            Pencil pencil      = new Pencil(5, 20, 20, "a");
            string textToErase = "a";

            pencil.Erase(textToErase);
            Assert.AreEqual(19, pencil.EraserDurability);
        }
Example #20
0
        public void WhenPencilErases_EraserIsNotReducedByWhitespaceCharacters()
        {
            pencil = new Pencil(defaultDurability, defaultLength, defaultEraser);
            sheet  = new Paper("Unless you are trying to change nothing");

            pencil.Erase("trying to change", sheet);
            Assert.AreEqual(defaultEraser - 14, pencil.Eraser);
        }
Example #21
0
        public void WhenPencilErases_EraserIsReducedByNumOfNonwhitespaceCharacters()
        {
            pencil = new Pencil(defaultDurability, defaultLength, defaultEraser);
            sheet  = new Paper("Except when they do");

            pencil.Erase("when", sheet);
            Assert.AreEqual(defaultEraser - 4, pencil.Eraser);
        }
Example #22
0
        public void WhenAPencilErasesItDegradesByOne()
        {
            pencil = new Pencil(100, 8, 5);
            paper.AddContent("Erase");
            pencil.Erase(paper, "Erase");

            Assert.AreEqual(0, pencil.eraserDurability);
        }
Example #23
0
        public void WhenAPencilErasesBeyondItsDurabilityDoNotRemoveRemainingText()
        {
            pencil = new Pencil(100, 8, 5);
            paper.AddContent("What Remains");
            pencil.Erase(paper, "What Remains");

            Assert.AreEqual("What Re     ", paper.content);
        }
Example #24
0
        public void Pencil_Erase_Empty_Paper_Does_Nothing()
        {
            var pncl = new Pencil(1000, 10, 50);
            var ppr  = new Paper();

            Assert.That(pncl.Erase(ppr, "zap"), Is.EqualTo(false));
            Assert.That(ppr.Text, Is.EqualTo(""));
        }
Example #25
0
        public void Pencil_Erase_White_Space_Doesnt_Degrade_Eraser()
        {
            var pncl = new Pencil(1000, 10, 50);
            var ppr  = new Paper();

            pncl.Write(ppr, "The quick brown fox jumped over the lazy dog");
            Assert.That(pncl.Erase(ppr, "fox jumped over"), Is.EqualTo(true));
            Assert.That(pncl.EraserLength, Is.EqualTo(37));
        }
Example #26
0
        public void Pencil_Erase_Long_Text_Degrades_Eraser()
        {
            var pncl = new Pencil(10000, 10, 10000);
            var ppr  = new Paper();

            pncl.Write(ppr, new string('a', 9000));
            Assert.That(pncl.Erase(ppr, new string('a', 8500)), Is.EqualTo(true));
            Assert.That(pncl.EraserLength, Is.EqualTo(1500));
        }
Example #27
0
        public void Pencil_Erase_Short_Text_Degrades_Eraser()
        {
            var pncl = new Pencil(1000, 10, 50);
            var ppr  = new Paper();

            pncl.Write(ppr, "The quick brown fox jumped over the lazy dog");
            Assert.That(pncl.Erase(ppr, "v"), Is.EqualTo(true));
            Assert.That(pncl.EraserLength, Is.EqualTo(49));
        }
Example #28
0
        public void Pencil_Erase_Null_Text()
        {
            var pncl = new Pencil(1000, 10, 50);
            var ppr  = new Paper();

            pncl.Write(ppr, "The quick brown fox jumped over the lazy dog");
            Assert.That(pncl.Erase(ppr, null), Is.EqualTo(true));
            Assert.That(ppr.Text, Is.EqualTo("The quick brown fox jumped over the lazy dog"));
        }
Example #29
0
        public void Pencil_Erase_Complete_Text()
        {
            var pncl = new Pencil(10000, 10, 10000);
            var ppr  = new Paper();

            pncl.Write(ppr, LorumIpsum.Text);
            Assert.That(pncl.Erase(ppr, LorumIpsum.Text), Is.EqualTo(true));
            Assert.That(ppr.Text, Is.EqualTo(new string(' ', LorumIpsum.Text.Length)));
        }
Example #30
0
        public void Pencil_Erase_Long_Text()
        {
            var pncl = new Pencil(10000, 10, 10000);
            var ppr  = new Paper();

            pncl.Write(ppr, LorumIpsum.Text);
            Assert.That(pncl.Erase(ppr, LorumIpsum.MiddleChunk), Is.EqualTo(true));
            Assert.That(ppr.Text, Is.EqualTo(LorumIpsum.Text.Replace(LorumIpsum.MiddleChunk, new string(' ', LorumIpsum.MiddleChunk.Length))));
        }