I would like to create a method that can take a method name and verify if method was called. I have implemented the following coed block and wanted to investigate if there is a better way to do it
<code>
private void Then_WirelessDeviceCalledMethod(ushort unitId, string methodName = null)
{
var wdm = GetWirelessDeviceMock(unitId);
bool invoked = false;
foreach (var invocation in wdm.Invocations)
{
if (invocation.Method.Name == methodName)
{
invoked = true;
}
}
Assert.That(invoked, Is.True);
}
</code>
<code>
private void Then_WirelessDeviceCalledMethod(ushort unitId, string methodName = null)
{
var wdm = GetWirelessDeviceMock(unitId);
bool invoked = false;
foreach (var invocation in wdm.Invocations)
{
if (invocation.Method.Name == methodName)
{
invoked = true;
}
}
Assert.That(invoked, Is.True);
}
</code>
private void Then_WirelessDeviceCalledMethod(ushort unitId, string methodName = null)
{
var wdm = GetWirelessDeviceMock(unitId);
bool invoked = false;
foreach (var invocation in wdm.Invocations)
{
if (invocation.Method.Name == methodName)
{
invoked = true;
}
}
Assert.That(invoked, Is.True);
}
I have searched on the internet but could not find a satisfactory solution.