public async Task ShouldReturnUnspecifiedWhenBothCallbackAndNextComponentAreNull() { // Arrange var component = new CallbackComponent(() => null); var input = new TestAction("TEST"); var state = TestStateId.New; // Act var result = await component.Apply(input, state); // Assert Assert.Equal(StateMachineResponse.Unspecified.Id, result.Response.Id); }
public async Task ShouldReturnUnspecifiedWhenNextComponentIdNullAndCallbackIsNotOfValidType() { // Arrange var component = new CallbackComponent(() => Mock.Of <ITransitionCallback <string> >(MockBehavior.Strict)); var input = new TestAction("TEST"); var state = TestStateId.New; // Act var result = await component.Apply(input, state); // Assert Assert.Equal(StateMachineResponse.Unspecified.Id, result.Response.Id); }
public async Task ShouldReturnUnspecifiedResponseWhenComponentIsNull() { // Arrange var component = new CallbackComponent(() => this.callback); var input = new TestAction("TEST"); var state = TestStateId.New; Mock.Get(this.callback) .Setup(c => c.Execute(input)) .Returns(Task.CompletedTask); // Act var result = await component.Apply(input, state); // Assert Assert.Equal(StateMachineResponse.Unspecified.Id, result.Response.Id); }
public async Task ShouldReturnExceptionResponseWhenCallbackThrowsException() { // Arrange var component = new CallbackComponent(() => this.callback); var input = new TestAction("TEST"); var state = TestStateId.New; Mock.Get(this.callback) .Setup(c => c.Execute(input)) .ThrowsAsync(new InvalidOperationException()); // Act var result = await component.Apply(input, state); // Assert Assert.Equal(StateMachineResponse.Exception.Id, result.Response.Id); }
public async Task ShouldReturnSuccess() { // Arrange var component = new CallbackComponent(() => this.callback); var input = new TestAction("TEST"); var state = TestStateId.New; component.Add(this.next); Mock.Get(this.callback) .Setup(c => c.Execute(input)) .Returns(Task.CompletedTask); Mock.Get(this.next) .Setup(n => n.Apply(input, state)) .ReturnsAsync(new StateTransitionResponse(StateMachineResponse.Success, state)); // Act var result = await component.Apply(input, state); // Assert Assert.Equal(StateMachineResponse.Success.Id, result.Response.Id); }