Unit test modified so it is build pipeline friendly and does not break the tenants of good Unit Testing
The Unit Test
Code Block |
---|
| [Test]
|
// Redesign has worked so this test uses a stub to simulate a file being
// loaded, it is passed in as lambda - We've decoupled ourselves from the
// filesystem
@Test
public void load_all_of_file_using_delegate_with_stubbed_datavia_stub()
{
// arrange
String string fileToLoad = "c:/tmp/KeyboardHandler.java.txt";
FileLoader cut = new FileLoader(fileToLoad);
int expectedBytesRead = 5510;
// act
int bytesRead = cut.LoadFileloadFile(fileToLoad, (fname) =->
{
{ List<String> result = new ArrayList<>();
List<string> result = new();
result.Addadd("using NUnit.Framework;Hello");
result.Addadd("using System.Collections.Generic;world");
return result;
return result; });
});
// assert
Assert.AreEqualassertEquals(expectedBytesRead, bytesRead);
} |