public async Task GetWorkflowStateAsync_ReturnsEmptySessionStateTest() { // Arrange var expected = new SessionWorkflowState(); var mockSession = Mock.Of <IMessageSession>(MockBehavior.Strict); Mock.Get(mockSession) .Setup(s => s.GetStateAsync()) .ReturnsAsync(default(byte[])) .Verifiable(); var workflowStateManager = new WorkflowStateManager(); // Act var actual = await workflowStateManager.GetWorkflowStateAsync(mockSession); // Assert actual.Should().BeEquivalentTo(expected); Mock.Get(mockSession).Verify(); }
public async Task GetWorkflowStateAsync_ReturnsExpectedResultTest() { // Arrange var expected = new SessionWorkflowState { FailedMessageId = "test" }; var stateBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(expected)); var mockSession = Mock.Of <IMessageSession>(MockBehavior.Strict); Mock.Get(mockSession) .Setup(s => s.GetStateAsync()) .ReturnsAsync(stateBytes) .Verifiable(); var workflowStateManager = new WorkflowStateManager(); // Act var actual = await workflowStateManager.GetWorkflowStateAsync(mockSession); // Assert actual.Should().BeEquivalentTo(expected); Mock.Get(mockSession).Verify(); }