Esempio n. 1
0
        public void VerifyWhenDurabilityIsOneAndPencilWritesOneLetterTheSameLetterIsReturned()
        {
            PencilDurability pencilDurability = new PencilDurability(1, 1, 10);
            string           result           = pencilDurability.Write("t");

            Assert.Equal("t", result);
        }
Esempio n. 2
0
        public void VerifyWhenDurabilityIsOneAndPencilWritesACapitalLetterAnEmptyStringIsReturned()
        {
            PencilDurability pencilDurability = new PencilDurability(1, 1, 10);
            string           result           = pencilDurability.Write("A");

            Assert.Equal(string.Empty, result);
        }
Esempio n. 3
0
        public void VerifyWhenDurabilityIsTwoAndPencilWritesTwoLettersSameTwoLettersAreReturned()
        {
            PencilDurability pencilDurability = new PencilDurability(2, 1, 10);
            string           result           = pencilDurability.Write("te");

            Assert.Equal("te", result);
        }
Esempio n. 4
0
        public void VerifyWhenPencilIsSharpenedTheLengthIsReducedByOne()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 2, 10);

            pencilDurability.Sharpen();
            Assert.Equal(1, pencilDurability.GetLength());
        }
Esempio n. 5
0
        public void VerifyWhenPaperIsInitializedThenTextOnPaperCanBeRead()
        {
            PencilDurability pencilDurability = new PencilDurability(1, 1, 10);
            string           paper            = "Test paper";

            pencilDurability.InitializePaper(paper);
            Assert.Equal("Test paper", pencilDurability.GetPaperText());
        }
Esempio n. 6
0
        public void VerifyWhenDurabilityIsTwoAndPencilWritesOneLowerCaseLetterAndNewlineDurabilityIsOne()
        {
            PencilDurability pencilDurability = new PencilDurability(2, 1, 10);

            pencilDurability.Write("a\n");
            int durability = pencilDurability.GetPencilDurability();

            Assert.Equal(1, durability);
        }
Esempio n. 7
0
        public void VerifyWhenEditingTextAndPencilDurabilityIsZeroAndNewTextWouldHaveCollidedWithExistingTextResultingPaperOriginalTextRemains()
        {
            PencilDurability pencilDurability = new PencilDurability(0, 1, 1);
            string           paper            = "There is not room";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(0, "edit");
            Assert.Equal(paper, pencilDurability.GetPaperText());
        }
Esempio n. 8
0
        public void VerifyWhenEditingPaperAndNextTextCollidesWithTwoExistingWordsNextTextFillsWhiteSpaceAndAtSymbolReplacesCollidingLetters()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 1);
            string           paper            = "There is not room";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(8, "enough");
            Assert.Equal("There ise@@@g@oom", pencilDurability.GetPaperText());
        }
Esempio n. 9
0
        public void VerifyWhenPencilIsSharpenedAndLengthIsZeroInitialDurabilityIsNotRegained()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 0, 10);

            pencilDurability.Sharpen();
            pencilDurability.Write("test");
            pencilDurability.Sharpen();
            Assert.Equal(6, pencilDurability.GetPencilDurability());
        }
Esempio n. 10
0
        public void VerifyWhenPaperIsEditWithPencilDurabilityFourAndThreeUppercaseLettersOnlyFirstTwoCharactersAdded()
        {
            PencilDurability pencilDurability = new PencilDurability(4, 1, 3);
            string           paper            = "This is     paper";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(8, "THE");
            Assert.Equal("This is TH  paper", pencilDurability.GetPaperText());
        }
Esempio n. 11
0
        public void VerifyWhenPaperIsEditedWithThreeUppercaseLettersPencilDurabilityGoesDownBySix()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 3);
            string           paper            = "This is     paper";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(8, "THE");
            Assert.Equal(4, pencilDurability.GetPencilDurability());
        }
Esempio n. 12
0
        public void VerifyWhenPaperHasFiveConsecutiveWhiteSpacesWordTheCanBeAddedToMiddleThreeWhiteSpacesOnPaper()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 3);
            string           paper            = "This is     paper";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(8, "the");
            Assert.Equal("This is the paper", pencilDurability.GetPaperText());
        }
Esempio n. 13
0
        public void VerifyWhenEraserDurabilityIsThreeAndBillIsErasedThenOnlyFirstLetterOfBillRemains()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 3);
            string           paper            = "Buffalo Bill";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Erase("Bill");
            Assert.Equal("Buffalo B   ", pencilDurability.GetPaperText());
        }
Esempio n. 14
0
        public void VerifyWhenEraserDurabilityIsFiveAndWordBillIsErasedWithSpaceThenEraserDurabilityIsOne()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 5);
            string           paper            = "Buffalo Bill";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Erase(" Bill");
            Assert.Equal(1, pencilDurability.GetEraserDurability());
        }
Esempio n. 15
0
        public void VerifyWhenEraserDurabilityIsFourAndWordBillIsErasedThenEraserDurabilityIsZero()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 4);
            string           paper            = "Buffalo Bill";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Erase("Bill");
            Assert.Equal(0, pencilDurability.GetEraserDurability());
        }
Esempio n. 16
0
        public void VerifyWhenTheWordTestIsErasedThenLastOccurrenceOfTestOnPaperIsReplacedWithWhitespace()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 10);
            string           paper            = "Test my eraser test";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Erase("test");
            Assert.Equal("Test my eraser     ", pencilDurability.GetPaperText());
        }
Esempio n. 17
0
        public void VerifyWhenEditingPaperAndNewTextCollidesWithExistingTextAtSymbolIsWrittenInThatPosition()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 1);
            string           paper            = "There is not      room";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Edit(13, "enough");
            Assert.Equal("There is not enoug@oom", pencilDurability.GetPaperText());
        }
Esempio n. 18
0
        public void VerifyPencilAppendsTextToPaperWithExistingText()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 10);
            string           paper            = "Test paper";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Write(" appending");
            Assert.Equal("Test paper appending", pencilDurability.GetPaperText());
        }
Esempio n. 19
0
        public void VerifyWhenPencilIsSharpenedItRegainsInitialDurability()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 2, 10);

            pencilDurability.Sharpen();
            pencilDurability.Write("test");
            pencilDurability.Sharpen();
            Assert.Equal(10, pencilDurability.GetPencilDurability());
        }
Esempio n. 20
0
        public void VerifyWhenWordOccursTwiceOnPaperAndEraseCalledTwiceForThatWordBothOccurrencesAreErased()
        {
            PencilDurability pencilDurability = new PencilDurability(10, 1, 10);
            string           paper            = "test my eraser test";

            pencilDurability.InitializePaper(paper);
            pencilDurability.Erase("test");
            pencilDurability.Erase("test");
            Assert.Equal("     my eraser     ", pencilDurability.GetPaperText());
        }