There were some helper methods that I modified, like this one:
public void InsertPreTag() {
InsertTags(Tags.Pre);
}
I d like to get rid of those, because they don t communicate much and they re complicating the interface to the TextModel. Let s see what s using these methods and what we can do about it. In this case, there s just one test:
[Test] public void InsertPre() {
model.SetLines (new String[1] {"<P></P>"});
model.SelectionStart = 7;
model.InsertPreTag();
AssertEquals("<pre></pre>", model.Lines[1]);
AssertEquals(14, model.SelectionStart);
model.InsertReturn();
AssertEquals("<pre>", model.Lines[1]);
AssertEquals("</pre>", model.Lines[2]);
AssertEquals(16, model.SelectionStart);
}
Simple enough. We can and should use our new method directly:
[Test] public void InsertPre() {
model.SetLines (new String[1] {"<P></P>"});
model.SelectionStart = 7;
model.InsertTags(TextModel.Tags.Pre);
AssertEquals("<pre></pre>", model.Lines[1]);
AssertEquals(14, model.SelectionStart);
model.InsertReturn();
AssertEquals("<pre>", model.Lines[1]);
AssertEquals("</pre>", model.Lines[2]);
AssertEquals(16, model.SelectionStart);
}
Let s remove the other helper methods similarly:
public void InsertUnorderedList() {
InsertTags(Tags.UnorderedList);
}
public void InsertListItemTag() {
InsertTags(Tags.ListItem);
}
public void InsertParagraphTag() {
InsertTags(Tags.Paragraph);
}
I do these each in the same way: I copy the operational line from the method, delete the method, compile, and see where the errors are. I paste the operational line over the offending call. A couple of the uses of the helpers were inside TextModel itself, and some were in the tests. It was a matter of a couple of minutes, with the help of the compiler. When everything compiled, the tests ran.