I have an interface that has members, something like this:
public interface IDataLoader
{
//other stuff
// tools for loading the items to be processed from disk or cloud
CustomCollection ItemsToBeProcessed {get; set;}
}
I'm doing UTs for other components of the system that consume those ItemsToBeProcessed and I want to avoid the complexity and dependencies for the loading.
In every UT I want to fill the ItemsToBeProcessed with specific hardcoded data. Then feed the data to the module being tested (the processor module) and compare the output with specific hardcoded expected data.
My problem is that I cannot initialize this ItemsToBeProcessed and I don't get why.
This is my UT so far:
[Test]
public void DataProcessor_TestData1_asExpected()
{
Mock<IDataLoader> mokedAmplifier = new Mock<IDataLoader>(MockBehavior.Loose);
MainController.Loader = mokedAmplifier.Object;
if(MainController.Loader.ItemsToBeProcessed == null)
MainController.Loader.ItemsToBeProcessed = new CustomCollection();
// here the MainController.Loader.ItemsToBeProcessed is still null.. why???
var TestData = LoadTestData("testData1.xml");
var ExpectedData = LoadExpectedData("ExpectedData1.xml")
MainConroller.Loader.ItemsToBeProcessed.AddRange(TestData);
var ProcessingModuleBeingTested = new ProcessingModule();
var results = ProcessingModuleBeingTested.Process(MainController.Loader.ItemsToBeProcessed);
Asert.isEqual(ExepctedData, results);
}
Ho do I initialize this member?