I have the following method that I would like to unit test:
public void Upload(string identifier, Stream data)
{
var startTime = SystemTime.Now;
innerDataIntegrationInterface.Upload(identifier, data);
var endTime = SystemTime.Now;
TimeSpan totalUploadTime = endTime.Subtract(startTime);
float transferRate = data.Length / (float)(totalUploadTime.Seconds + totalUploadTime.Milliseconds);
m_log.Info(string.Format("Total uploading time for '{0}' was {1:00}.{2:000000} milliseconds transfered at {3} bytes/sec", identifier, totalUploadTime.Seconds, totalUploadTime.Milliseconds, transferRate));
}
Basically I am already injecting the SystemTime object so I can set it up in my test but I can’t figure out what to do so that the startTime and endTime variables get different values so I can assert that the m_log.Info method gets called with the correct values for the totalUploadTime and transferRate variables.
Any ideas would be appreciated.
Can you make your Mock
SystemTimeobject increment it’s value in theNowGetter? That would make them different.