You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you also reproduce the problem with the lastest version?
Yes.
Steps to Reproduce
Create a saga like this.
public class SagaState : SagaStateMachineInstance {
// This can also be string, the bug is still there
// The bug goes away if this is of the type State
public int CurrentState { get; set }
// .... other Saga State
}
Create a state machine.
public class MyStateMachine : MassTransitStateMachine<SagaState>
{
public State MyState { get; private set; }
// Maybe more states here
public Event<MyEvent> MyEvent { get; private set; }
public MyStateMachine()
{
InstanceState(x => x.CurrentState, MyState);
// Bug is also here if you switch to the InstanceState(x => x.CurrentState) when CurrentState is a string.
// Bug goes away if using the overload InstanceState(x => x.CurrentState) when CurrentState is of the type State.
// Perform other basic saga setup here.
Initially(When(MyEvent).TransitionTo(MyState));
}
}
With these very basic things in place, if we make a test using MassTransit.TestFramework that uses the ShouldContainSaga method on an InMemorySagaRepository...
await repo.ShouldContainSaga(x => x.Id == id && Equals(x.CurrentState, saga.MyState), TimeSpan.FromMinutes(1));
This will always wait 1 minutes. After one minute it might pass, but it will always wait the full timeout time causing incredibly slow tests.
Switching the type of the CurrentState property to State instead of int or string will cause the exact same code to perform as expected (very fast).
Of course, switching the type of the CurrentState property to State may lead to other problems if using some persistance options since that type is harder for some persistance options to serialize/deserialize (mongodb for example does not like that, but that can of course be fixed with a classmap). But switching this type is a workaround that seems to work properly.
The text was updated successfully, but these errors were encountered:
So the issue is the state isn't actually Equal, the instance state accessor should be used to convert the int/string to the State type for the comparison.
Is this a bug report?
Yes.
Can you also reproduce the problem with the lastest version?
Yes.
Steps to Reproduce
Create a saga like this.
Create a state machine.
With these very basic things in place, if we make a test using
MassTransit.TestFramework
that uses theShouldContainSaga
method on anInMemorySagaRepository
...This will always wait 1 minutes. After one minute it might pass, but it will always wait the full timeout time causing incredibly slow tests.
Switching the type of the CurrentState property to
State
instead ofint
orstring
will cause the exact same code to perform as expected (very fast).Of course, switching the type of the CurrentState property to
State
may lead to other problems if using some persistance options since that type is harder for some persistance options to serialize/deserialize (mongodb for example does not like that, but that can of course be fixed with a classmap). But switching this type is a workaround that seems to work properly.The text was updated successfully, but these errors were encountered: