I have a code which looks like example below:
public interface IDependency
{
void Foo();
}
public class MainClass{
Timer tmr = new Timer(100);
IDependency dependency;
public MainClass(IDependency dep)
{
dependency = dep;
tmr.Elapsed += OnElapsed;
}
void OnElapsed(object sender, EventArgs e)
{
dependency.Foo();
}
public void Start()=> tmr.Start();
public void Stop() => tmr.Stop();
}
Using RhinoMock and/or nunit, I want to unit-test that once 'Stop' is called, IDependency.Foo
is no longer being called
Tried using BackToRecord
and ReplayAll
, but could not achieve the goal. Calling AssertWasNotCalled
does not fail after calling Stop()
.
Is there any way to achieve the same?