Sample Test:
public class SetSearchStringExecutionMainTests
{
[Theory, NSubstituteCrmAutoData]
public void Constructor_HasNullGuards(GuardClauseAssertion assertion)
{
assertion.Verify(typeof (SetSearchStringExecutionMain).GetConstructors());
}
[Theory, NSubstituteCrmAutoData]
public void Constructor_Returnsobject(SetSearchStringExecutionMain sut)
{
Assert.IsAssignableFrom<IExecutionMain>(sut);
}
[Theory, NSubstituteCrmAutoData]
public void Methods_HaveNullGuards(GuardClauseAssertion assertion)
{
assertion.Verify(typeof (SetSearchStringExecutionMain).GetMethods());
}
[Theory, NSubstituteCrmAutoData]
public void Run_ExecutesUpdateEntityOnce(
[Frozen] IMessageDependentExecution messageDependentExecution,
SetSearchStringExecutionMain sut)
{
// Arrange
// Act
sut.Run();
// Assert
Assert.Equal(1, messageDependentExecution.ReceivedCalls().Count());
}
}
Sample Code:
public interface IExecutionMain
{
void Run();
}
public interface IMessageDependentExecution
{
void Run();
}
public class SetSearchStringExecutionMain : IExecutionMain
{
private readonly IMessageDependentExecution _messageDependentExecution;
public SetSearchStringExecutionMain(IMessageDependentExecution messageDependentExecution)
{
if (messageDependentExecution == null)
{
throw new ArgumentNullException(nameof(messageDependentExecution));
}
_messageDependentExecution = messageDependentExecution;
}
public void Run()
{
_messageDependentExecution.Run();
}
}