-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
In the following class, the Then method (ThenTheMessageShouldBeRetrievedFromTheContext()) runs first instead of the Given method (GivenTheContextIsValid()) (please ignore dumb debugging code in place only for breakpoints ;) ):
public class ShouldLogMessageBodyOnPreReceive
{
private Core.Observers.ReceiveObserver sut;
private Mock<ILogger> mockLog;
private Mock<ReceiveContext> context;
public ShouldLogMessageBodyOnPreReceive()
{
sut = new Core.Observers.ReceiveObserver();
mockLog = new Mock<ILogger>();
Core.Observers.ReceiveObserver.Log = mockLog.Object;
}
void GivenTheContextIsValid()
{
int x = 1;
}
void WhenTheMethodIsInvoked()
{
int x = 1;
}
void ThenTheMessageShouldBeRetrievedFromTheContext()
{
int x = 0;
}
void AndTheMessageShouldBeLogged()
{
int x = 0;
}
}
Renaming the then method from ThenTheMessageShouldBeRetrievedFromTheContext to ThenWeShouldGetTheMessageBody corrects the issue and the methods run in the correct order:
public class ShouldLogMessageBodyOnPreReceive
{
private Core.Observers.ReceiveObserver sut;
private Mock<ILogger> mockLog;
private Mock<ReceiveContext> context;
public ShouldLogMessageBodyOnPreReceive()
{
sut = new Core.Observers.ReceiveObserver();
mockLog = new Mock<ILogger>();
Core.Observers.ReceiveObserver.Log = mockLog.Object;
}
void GivenTheContextIsValid()
{
int x = 1;
}
void WhenTheMethodIsInvoked()
{
int x = 1;
}
void ThenWeShouldGetTheMessageBody()
{
int x = 0;
}
void AndTheMessageShouldBeLogged()
{
int x = 0;
}
}
Metadata
Metadata
Assignees
Labels
No labels