Exemple #1
0
 public void Sharpen(IPencil pencil)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.Write("sharpening the pencil...");
     Console.ResetColor();
     pencil.AfterSharpening();
 }
        public void sharpenPencil(IPencil pencil)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Sharpning the pencil...");
            Console.ResetColor();

            pencil.afterSharpening();
        }
 public void Sharpen(IPencil pencil)
 {
     //We are sharpening the pencil that passed in as a parameter. Now it can write to max again.
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("Sharpening the pencil...");
     Console.ResetColor();
     pencil.AfterSharpening();
 }
        public void Sharpen(IPencil pencil)
        {
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Sharpening pencil...");
            Console.ResetColor();

            pencil.AfterSharpening();
        }
Exemple #5
0
                public void ShouldNeverBecomeNegative(string sentence, int startPointDurability)
                {
                    const int expectedPointDurability = 0;
                    IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), sentence);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #6
0
                public void ShouldReplaceMatchingTextWithCorrectAmountOfSpaces(string testWord, string expected)
                {
                    IPencil pencil = GetPencil();
                    IPaper  paper  = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.Equal(expected, paper.Text);
                }
Exemple #7
0
            public void ShouldMakeValuePositiveForNegativeLength()
            {
                const int startLength    = -10;
                const int expectedLength = 10;

                IPencil pencil = GetPencil(length: startLength);

                Assert.Equal(expectedLength, pencil.CurrentLength);
            }
Exemple #8
0
            public void ShouldMakeValuePositiveForNegativeEraserDurability()
            {
                const int startEraserDurability    = -10;
                const int expectedEraserDurability = 10;

                IPencil pencil = GetPencil(eraserDurability: startEraserDurability);

                Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
            }
Exemple #9
0
                public void ShouldDegradeCorrectlyForMixedCaseAndWhitespace(string mixedString, int degradeAmount)
                {
                    const int startPointDurability    = 40;
                    int       expectedPointDurability = startPointDurability - degradeAmount;
                    IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), mixedString);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #10
0
                public void ShouldDegradCorrectlyforManyRandomCharacters(string miscCharacters)
                {
                    const int startPointDurability    = 20;
                    int       expectedPointDurability = startPointDurability - miscCharacters.Length;
                    IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), miscCharacters);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #11
0
                public void ShouldDegradeCorrectlyForManyLowercaseLetters(string lowercaseLetters)
                {
                    const int startPointDurability    = 20;
                    int       expectedPointDurability = startPointDurability - lowercaseLetters.Length;
                    IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), lowercaseLetters);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #12
0
                public void ShouldAddTextToPaper()
                {
                    const string testSentence = "This is a sentence";
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper();

                    pencil.Write(paper, testSentence);

                    Assert.Equal(testSentence, paper.Text);
                }
Exemple #13
0
                public void ShouldRemoveMatchingText()
                {
                    const string testWord = "word";
                    IPencil      pencil   = GetPencil();
                    IPaper       paper    = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.DoesNotContain(testWord, paper.Text);
                }
Exemple #14
0
            public void ShouldNotAllowLengthToBecomeNegative()
            {
                const int startLength    = 0;
                const int expectedLength = 0;
                IPencil   pencil         = GetPencil(length: startLength);

                pencil.Sharpen();

                Assert.Equal(expectedLength, pencil.CurrentLength);
            }
Exemple #15
0
            public void ShouldSharpenToThePositiveValueForNegativeDurability()
            {
                const int startPointDurability    = -10;
                const int expectedPointDurability = 10;
                IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                pencil.Sharpen();

                Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
            }
Exemple #16
0
            public void ShouldReducePencilLengthByOne()
            {
                const int startLength    = 5;
                const int expectedLength = 4;
                IPencil   pencil         = GetPencil(length: startLength);

                pencil.Sharpen();

                Assert.Equal(expectedLength, pencil.CurrentLength);
            }
Exemple #17
0
                public void ShouldNeverBecomeNegative(string sentence, int startEraserDurability)
                {
                    const int expectedEraserDurability = 0;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(sentence);

                    pencil.Erase(paper, sentence);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
Exemple #18
0
                public void ShouldDoNothingIfNoMatchIsFound()
                {
                    const string testSentence = "Not this or this";
                    const string eraseWord    = "test";
                    IPencil      pencil       = GetPencil();
                    IPaper       paper        = GetPaper(testSentence);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(testSentence, paper.Text);
                }
Exemple #19
0
            public void ShouldResetDurabilityToOriginalValue()
            {
                const string testSentence    = "Text to waste pencil durability for testing sharpening abilities";
                const int    pointDurability = 100;
                IPencil      pencil          = GetPencil(pointDurability: pointDurability);

                pencil.Write(GetPaper(), testSentence);
                pencil.Sharpen();

                Assert.Equal(pointDurability, pencil.CurrentPointDurability);
            }
Exemple #20
0
                public void ShouldWriteWhitespaceCharacters()
                {
                    const string testWhitespace  = "  \t\r\n\f\v  ";
                    const int    pointDurability = 0;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper();

                    pencil.Write(paper, testWhitespace);

                    Assert.Equal(testWhitespace, paper.Text);
                }
Exemple #21
0
                public void ShouldDegradeByTwoWhenWritingInUppercase()
                {
                    const string uppercaseLetter         = "A";
                    const int    startPointDurability    = 5;
                    const int    expectedPointDurability = 3;
                    IPencil      pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), uppercaseLetter);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #22
0
                public void ShouldDoNothingWithNoDurability()
                {
                    const string testSentence     = "  \v0?>9\n<8:6 (*4&\t^2# 1$%  ";
                    const int    eraserDurability = 0;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(testSentence);

                    pencil.Erase(paper, testSentence);

                    Assert.Equal(testSentence, paper.Text);
                }
Exemple #23
0
                public void ShouldDegradeCorrectlyForMixedCharactersAndWhitespace(string mixedString, int degradeAmount)
                {
                    const int startEraserDurability    = 50;
                    int       expectedEraserDurability = startEraserDurability - degradeAmount;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(mixedString);

                    pencil.Erase(paper, mixedString);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
Exemple #24
0
                public void ShouldDegradeCorrectlyForManyCharacters(string eraseMatch)
                {
                    const int startEraserDurability    = 50;
                    int       expectedEraserDurability = startEraserDurability - eraseMatch.Length;
                    IPencil   pencil = GetPencil(eraserDurability: startEraserDurability);
                    IPaper    paper  = GetPaper(eraseMatch);

                    pencil.Erase(paper, eraseMatch);

                    Assert.Equal(expectedEraserDurability, pencil.CurrentEraserDurability);
                }
Exemple #25
0
                public void ShouldReplaceWhitespaceWithSpaces()
                {
                    const string testWhitespace = "  \t\r\n\f\v  ";
                    const string expected       = "         ";
                    IPencil      pencil         = GetPencil();
                    IPaper       paper          = GetPaper(testWhitespace);

                    pencil.Erase(paper, testWhitespace);

                    Assert.Equal(expected, paper.Text);
                }
Exemple #26
0
                public void ShouldDegradeCorrectlyForManyUppercaseLetters(string uppercaseLetters)
                {
                    const int uppercaseDegradeValue   = 2;
                    const int startPointDurability    = 40;
                    int       expectedPointDurability = startPointDurability - (uppercaseLetters.Length * uppercaseDegradeValue);
                    IPencil   pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), uppercaseLetters);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #27
0
                public void ShouldDefaultDegradingByOneIfNotWhitespaceOrUppercase()
                {
                    const string otherCharecter          = "?";
                    const int    startPointDurability    = 5;
                    const int    expectedPointDurability = 4;
                    IPencil      pencil = GetPencil(pointDurability: startPointDurability);

                    pencil.Write(GetPaper(), otherCharecter);

                    Assert.Equal(expectedPointDurability, pencil.CurrentPointDurability);
                }
Exemple #28
0
                public void ShouldWriteCorrectNumberOfSpaces()
                {
                    const string testSentence    = "This should not be written.";
                    const string expectedString  = "                           ";
                    const int    pointDurability = 0;
                    IPencil      pencil          = GetPencil(pointDurability: pointDurability);
                    IPaper       paper           = GetPaper();

                    pencil.Write(paper, testSentence);

                    Assert.Equal(expectedString, paper.Text);
                }
Exemple #29
0
                public void ShouldErasePartOfMatchingWord()
                {
                    const string testWord         = "word";
                    const string expectedWord     = "wo  ";
                    const int    eraserDurability = 2;
                    IPencil      pencil           = GetPencil(eraserDurability: eraserDurability);
                    IPaper       paper            = GetPaper(testWord);

                    pencil.Erase(paper, testWord);

                    Assert.Equal(expectedWord, paper.Text);
                }
Exemple #30
0
                public void ShouldMatchOnCaseWhenMatching()
                {
                    const string paperText        = "This but not this";
                    const string eraseWord        = "This";
                    const string expectedSentence = "     but not this";
                    IPencil      pencil           = GetPencil();
                    IPaper       paper            = GetPaper(paperText);

                    pencil.Erase(paper, eraseWord);

                    Assert.Equal(expectedSentence, paper.Text);
                }