Ejemplo n.º 1
0
        public void WhenOverwritingTheValueAppearsOnThePaper(string text, string expectedResult)
        {
            var testString = "An apple a day keeps the doctor away";

            var pencil = new Pencil(1000, 5, 100);
            var paper  = new Paper();

            pencil.Write(testString, ref paper);
            pencil.Erase("apple", ref paper);
            pencil.Rewrite(text, ref paper);

            Assert.Equal(expectedResult, paper.Content);
        }
Ejemplo n.º 2
0
        public void WhenRewritingNothingItDoesNotThrowEx()
        {
            var pencil = new Pencil();
            var paper  = new Paper();

            try
            {
                pencil.Rewrite(string.Empty, ref paper);
            }
            catch
            {
                Assert.True(false, "Exception thrown when calling Rewrite");
            }
        }
Ejemplo n.º 3
0
        public void WhenOverwritingThePointDurabilityIsReduced(string text, int expectedResult)
        {
            var testString        = "An apple a day keeps the doctor away";
            var initialDurability = 1000;

            var pencil = new Pencil(initialDurability, 5, 100);
            var paper  = new Paper();

            pencil.Write(testString, ref paper);
            pencil.Sharpen();
            pencil.Erase("apple", ref paper);
            pencil.Rewrite(text, ref paper);

            Assert.Equal(initialDurability - expectedResult, pencil.Durability);
        }