The rules are:
- It must be a unit test (so don't touch the file system).
- The public signature for
CodeUnderTest
must not be changed.can be extended not reduced - You're allowed to use DI/your favorite mocking framework.
- You can only add code where you see /**/.
[Test]
public void Test()
{
/**/
var text = CodeUnderTest.GetUpperText("foo.txt" /**/);
Assert.That(text, Is.EqualTo("BAR"));
/**/
}
public class CodeUnderTest
{
/**/
public static string GetUpperText(string path /**/)
{
var text = File.ReadAllText(path);
return text.ToUpperInvariant();
}
/**/
}
Please comment below or tweet me @jcansdale.
Dammit, I should have known someone would do that! ๐
How about we change the test to this?
Also, assume the test is being called from an external assembly and no
InternalsVisibleToAttribute
funny business!BTW, I was hoping you would bite, being the resident DI guru. It's good to have your thoughts!