Exemplo n.º 1
0
 public void GivenAPencil_WhenSharpenedWithZeroLength_ThenThePencilsLengthDoesNotGoNegative()
 {
     _sut = new Pencil(length: 0);
     _sut.WriteOn("Stuff", _forgivingMoq.Object);
     _sut.Sharpen();
     _sut.Sharpen();
     Assert.Equal(0u, _sut.Length);
 }
Exemplo n.º 2
0
        public void WhenPencilIsSharpened_SharpnessReturnsToInitialDurability()
        {
            pencil.Write("Sharpness is getting reduced.", sheet);
            Assert.AreEqual(defaultDurability - 27, pencil.Sharpness);

            pencil.Sharpen();
            Assert.AreEqual(defaultDurability, pencil.Sharpness);
        }
Exemplo n.º 3
0
        public void TestPencilRegainsDurabilityAfterSharpening()
        {
            // Act
            pencil.Write(genericTestSentence);
            pencil.Sharpen();

            // Assert
            Assert.AreEqual(pencil.MaxDurability, pencil.CurrentDurability, "Pencil durability should match max durability after sharpened");
        }
Exemplo n.º 4
0
        public void When_SharpenIsUsedTwice_Expect_LengthToBeReducedByTwo()
        {
            var startingLength = 3;
            var pencil         = new Pencil(paperMock.Object, 0, startingLength, 0);

            pencil.Sharpen();
            pencil.Sharpen();
            Assert.AreEqual(pencil.Length, 1);
        }
Exemplo n.º 5
0
        public void Pencil_WhenMaxSharpeningsReached_Throws()
        {
            var paper  = new Paper();
            var eraser = new Eraser(paper, 20);
            var pencil = new Pencil(new PencilProperties()
            {
                Paper = paper, PointDegradation = 10, MaxNumberOfSharpenings = 1, Eraser = eraser
            });

            pencil.Sharpen(); //first time to get the count to 0
            Assert.ThrowsException <Exception>(() => pencil.Sharpen(), ExceptionMessages.PencilOutOfSharpening);
        }
Exemplo n.º 6
0
 public void WhenPencilWithLengthGreaterThanZeroIsSharpenedDurabilityIsRestored()
 {
     pencil = new Pencil(20, 5, 10);
     pencil.Write("", "Mary had");
     pencil.Sharpen(pencil.Length);
     Assert.Equal(20, pencil.Durability);
 }
Exemplo n.º 7
0
        public static void SelectOptions(Pencil pencil, PaperModel paper)
        {
            Console.WriteLine();
            Console.WriteLine("Pick your next action by entering the corresponding number");
            Console.WriteLine("1. Write More");
            Console.WriteLine("2. Erase a Word");
            Console.WriteLine("3. Sharpen Your Pencil");
            Console.WriteLine("4. Exit the Program");
            int.TryParse(Console.ReadLine(), out int userChoice);

            switch (userChoice)
            {
            case 1:
                WriteMore(pencil, paper);
                break;

            case 2:
                EraseAWord(pencil, paper);
                break;

            case 3:
                pencil.Sharpen();
                Console.WriteLine();
                Console.WriteLine("Remaining sharpens: " + pencil.PencilLength);
                Console.WriteLine();
                SelectOptions(pencil, paper);
                break;

            case 4:
                Console.WriteLine("Goodbye");
                break;
            }
        }
Exemplo n.º 8
0
        public void UsingSharpenMethodDecrementsPencilLengthByOne()
        {
            //Assert

            var lengthAfterSharpening = 3;
            var aWord = "A word";

            Paper = new PaperModel();

            //Act
            HydratedPencil.WriteInputOntoPaper(aWord, Paper);
            HydratedPencil.Sharpen();

            //Assert
            Assert.AreEqual(lengthAfterSharpening, HydratedPencil.PencilLength);
        }
Exemplo n.º 9
0
        public void WhenSharpenCalledIfLengthIs0PointDurabilityWontBeReset()
        {
            Pencil pencil = new Pencil(0, 19);

            pencil.Sharpen();
            Assert.AreEqual(19, pencil.PointDurability);
        }
Exemplo n.º 10
0
 public void WhenPencilLengthIsZeroThePencilDurabilityIsNotChangedIfSharpened()
 {
     pencil = new Pencil(10, 0, 10);
     pencil.Write("", "little ");
     pencil.Sharpen(pencil.Length);
     Assert.Equal(4, pencil.Durability);
 }
Exemplo n.º 11
0
 public void GivenAPencil_WhenSharpenedWithZeroLength_ThenThePencilsDurabilityRemainsUntouched()
 {
     _sut = new Pencil(length: 0);
     _sut.WriteOn("Games Done Quick", _forgivingMoq.Object);
     _sut.Sharpen();
     Assert.Equal(83u, _sut.Durability);
 }
Exemplo n.º 12
0
        public void WhenSharpenCalledCurrentPointDurabilityIsResetToInitialPointDurability()
        {
            Pencil pencil = new Pencil(5, 20);

            pencil.Sharpen();
            Assert.AreEqual(20, pencil.PointDurability);
        }
Exemplo n.º 13
0
 public void WhenAPencilIsSharpenedItReturnsToItsMaxDurability()
 {
     pencil = new Pencil(10, 8);
     paper.AddContent(pencil.Write("12345"));
     pencil.Sharpen();
     Assert.AreEqual(10, pencil.durability);
 }
Exemplo n.º 14
0
        public void WhenLengthIs5AndSharpenCalledLengthIsReducedBy1()
        {
            Pencil pencil = new Pencil(5);

            pencil.Sharpen();
            Assert.AreEqual(4, pencil.Length);
        }
Exemplo n.º 15
0
        public void Pencil_Sharpen_Full_Durability_No_Length_Durability_Effect()
        {
            var pncl = new Pencil(10000, 5, 50);
            var ppr  = new Paper();

            Assert.That(pncl.Sharpen(), Is.EqualTo(true));
            Assert.That(pncl.Durability, Is.EqualTo(10000));
        }
Exemplo n.º 16
0
        public void WhenAPencilIsSharpenedItsDurabilityIsReset()
        {
            pencil = new Pencil(10, 8);
            paper.AddContent(pencil.Write("hello"));
            pencil.Sharpen();

            Assert.AreEqual(10, pencil.durability);
        }
Exemplo n.º 17
0
        public void WhenThePencilIsSharpenedTheLengthDecreasesByOne()
        {
            var pencil = new Pencil(25, 3);

            pencil.Sharpen();

            Assert.AreEqual(2, pencil.Length);
        }
Exemplo n.º 18
0
        public void WhenPencilLengthIsZeroAndIsSharpened_PencilSharpnessAndLengthRemainUnchanged()
        {
            pencil = new Pencil(defaultDurability, 0);

            pencil.Write("Sharpness is in the eye of the beholder.", sheet);
            pencil.Sharpen();
            Assert.AreEqual(defaultDurability - 34, pencil.Sharpness);
            Assert.AreEqual(0, pencil.Length);
        }
Exemplo n.º 19
0
        public void WhenThePencilHasLengthZeroSharpeningThePencilDoesNotRestorePointDurability()
        {
            var pencil = new Pencil(25, 0);

            pencil.Write("la dee da de da");
            pencil.Sharpen();

            Assert.AreNotEqual(25, pencil.PointDurability);
        }
Exemplo n.º 20
0
        public void WhenThePencilIsSharpenedItRegainsItsInitialPointDurability()
        {
            var pencil = new Pencil(25, 3);

            pencil.Write("la de da dee daa");

            pencil.Sharpen();
            Assert.AreEqual(25, pencil.PointDurability);
        }
Exemplo n.º 21
0
        public void When_Sharpen_Expect_LengthIsReduced()
        {
            var durability     = 3;
            var startingLength = 3;
            var pencil         = new Pencil(paperMock.Object, durability, startingLength, 0);

            pencil.Sharpen();
            Assert.Less(pencil.Length, startingLength);
        }
Exemplo n.º 22
0
        public void Pencil_Sharpen_Zero_Length_No_Durability_Effect()
        {
            var pncl = new Pencil(10000, 0, 50);
            var ppr  = new Paper();

            Assert.That(pncl.Sharpen(), Is.EqualTo(false));
            Assert.That(pncl.Durability, Is.EqualTo(10000));
            Assert.That(pncl.Length, Is.EqualTo(0));
        }
Exemplo n.º 23
0
        public void Sharpen_PencilLength_Test()
        {
            Pencil _pencil = new Pencil(4000, 20, 1000);

            _pencil.Write("She sells sea shells");

            _pencil.Sharpen();

            Assert.AreEqual(3999, _pencil.PencilLength);
        }
Exemplo n.º 24
0
        public void Pencil_Sharpen_Decreases_Length()
        {
            var pncl = new Pencil(10000, 5, 50);
            var ppr  = new Paper();

            pncl.Write(ppr, "a");
            pncl.Sharpen();

            Assert.That(pncl.Length, Is.EqualTo(4));
        }
Exemplo n.º 25
0
        public void WhenSharpenMethodCalledDurabilityIsSetToOriginalDurability()
        {
            Pencil pencil = new Pencil(10, 5);
            Paper  paper  = new Paper();

            pencil.Write("Text", paper);
            pencil.Sharpen();

            Assert.AreEqual(pencil.OriginalDurability, pencil.CurrentDurability);
        }
Exemplo n.º 26
0
        public void WhenPencilHasLengthOfNegativeOneAndIsSharpened_PencilIsSharpenedAndLengthRemainsNegativeOne()
        {
            pencil = new Pencil(defaultDurability, -1);

            pencil.Write("Sharpness is in the eye of the beholder.", sheet);
            Assert.AreEqual(defaultDurability - 34, pencil.Sharpness);
            pencil.Sharpen();
            Assert.AreEqual(defaultDurability, pencil.Sharpness);
            Assert.AreEqual(-1, pencil.Length);
        }
Exemplo n.º 27
0
        public void When_Sharpen_Expect_DurabilityToReturnToStartingValue()
        {
            var startingDurability = 2;
            var pencil             = new Pencil(paperMock.Object, startingDurability, 1, 0);

            pencil.Write("a");
            Assert.Less(pencil.Durability, startingDurability);
            pencil.Sharpen();
            Assert.AreEqual(pencil.Durability, startingDurability);
        }
Exemplo n.º 28
0
        private void SharpenOneValue(int pencilTip)
        {
            Pencil pencil = new Pencil(pencilTip);

            pencil.Write(phrase14toWrite12toErasewithWhitespace);
            pencil.Sharpen();
            actualInt = pencil.GetTip();

            Assert.AreEqual(pencilTip, actualInt);
        }
Exemplo n.º 29
0
        public void Sharpen_Degregation_Test()
        {
            Pencil _pencil = new Pencil(4000, 20, 1000);

            _pencil.Write("She sells sea shells");

            _pencil.Sharpen();

            Assert.AreEqual(20, _pencil.PointDegradation);
        }
Exemplo n.º 30
0
        public void SharpenMethodDoesNotExecuteIfLength0()
        {
            Pencil pencil = new Pencil(10, 0);
            Paper  paper  = new Paper();

            pencil.Write("Text", paper);
            pencil.Sharpen();


            Assert.AreEqual(5, pencil.CurrentDurability);
        }