public void TestEraserRemovesWordAsEntered() { // Act paper.Text += pencil.Write(testSentence); paper.Text = eraser.Erase(testWord, paper.Text); // Assert Assert.AreEqual(testSentenceWithWhiteSpace, paper.Text, "Test sentence should match paper text, eraser should remove entered word"); }
public void EraseWhiteSpaceHasNoCost() { var eraser = new Eraser(1); var stringBuilder = new StringBuilder(); stringBuilder.Append(eraser.Erase(' ')); stringBuilder.Append(eraser.Erase('j')); stringBuilder.Append(eraser.Erase(' ')); Assert.Equal(" ", stringBuilder.ToString()); }
/// <summary> /// Erases the types in <paramref name="vc" /> (if program is polymorphic) and sort let binding. /// Note that this has a side-effect on <paramref name="vc" />.. /// </summary> public VCExpr EraseAndSortLet(VCExpr vc, int polarity = -1) { var exprWithoutTypes = ProgramIsPolymorphic ? Eraser.Erase(vc, polarity) : vc; var letSorter = new LetBindingSorter(_vcExprGen); Contract.Assert(letSorter != null); return(letSorter.Mutate(exprWithoutTypes, true)); }
public void WhenCurrentDurabilityIsZeroEraseMethodWillStopErasing() { Pencil pencil = new Pencil(20, 5); Paper paper = new Paper(); Eraser eraser = new Eraser(5); pencil.Write("hello world!", paper); eraser.Erase("hello world!", paper); Assert.AreEqual("hello w ", paper.Text); }
public void WhenEraseMethodCalledEraserDurabilityDecreasesByOneForNonSpaceCharacters() { Pencil pencil = new Pencil(20, 5); Paper paper = new Paper(); Eraser eraser = new Eraser(20); pencil.Write("hello world!", paper); eraser.Erase("hello world!", paper); Assert.AreEqual(9, eraser.CurrentDurability); }
public void WhenEraseMethodCalledRemovesLastInstanceOfParameterString() { Pencil pencil = new Pencil(20, 20); Paper paper = new Paper(); Eraser eraser = new Eraser(20); pencil.Write("Hello World!", paper); eraser.Erase("World", paper); Assert.AreEqual("Hello !", paper.Text); }
public void WhenEditMethodCalledAddsCharsAtIndexWithoutCollision() { Pencil pencil = new Pencil(500, 5); Paper paper = new Paper(); Eraser eraser = new Eraser(20); pencil.Write("Hello World", paper); eraser.Erase("World", paper); pencil.Edit("Howdy", paper); Assert.AreEqual("Hello Howdy", paper.Text); }
public void WhenEditMethodCalledIfOverwriteCharIsSpaceDoNotReplaceOriginalChar() { Pencil pencil = new Pencil(500, 5); Paper paper = new Paper(); Eraser eraser = new Eraser(20); pencil.Write("Hello World", paper); eraser.Erase("Wor", paper); pencil.Edit("hey u", paper); Assert.AreEqual("Hello heyl@", paper.Text); }
public void WhenEditMethodCalledIfCharsCollideExistingCharOverwrittenWithSpecialChar() { Pencil pencil = new Pencil(500, 5); Paper paper = new Paper(); Eraser eraser = new Eraser(20); pencil.Write("Hello World", paper); eraser.Erase("lo", paper); pencil.Edit("Howdy", paper); Assert.AreEqual("HelHow@@rld", paper.Text); }
public void EraseReturnsAllCharacters() { var eraser = new Eraser(1000); var stringBuilder = new StringBuilder(); for (var i = 0; i < 5; i++) { stringBuilder.Append(eraser.Erase('J')); } Assert.Equal(" ", stringBuilder.ToString()); }
public void EraseReturnsAllWhiteSpace() { var eraser = new Eraser(0); var stringBuilder = new StringBuilder(); for (var i = 0; i < 5; i++) { stringBuilder.Append(eraser.Erase('j')); } Assert.Equal("jjjjj", stringBuilder.ToString()); }
public PaperModel UseEraser(string input, PaperModel paper) { paper = Eraser.Erase(input, paper); IndexOfLastErasedWord = paper.SpaceWhereErasedWordWas; return(paper); }