private static void AssertGetLatestReturnsCorrectly(ProjectUpdateBatch projectUpdateBatch, ProjectUpdateHistory expectedProjectUpdateHistory, ProjectUpdateState projectUpdateStateExpected) { Assert.That(projectUpdateBatch.ProjectUpdateHistories.GetLatestProjectUpdateHistory(), Is.EqualTo(expectedProjectUpdateHistory), "Should have gotten the correct latest one"); AssertGetLatestForTransitionReturnsCorrectly(projectUpdateBatch, expectedProjectUpdateHistory, projectUpdateStateExpected, ProjectUpdateState.Created); AssertGetLatestForTransitionReturnsCorrectly(projectUpdateBatch, expectedProjectUpdateHistory, projectUpdateStateExpected, ProjectUpdateState.Submitted); AssertGetLatestForTransitionReturnsCorrectly(projectUpdateBatch, expectedProjectUpdateHistory, projectUpdateStateExpected, ProjectUpdateState.Approved); AssertGetLatestForTransitionReturnsCorrectly(projectUpdateBatch, expectedProjectUpdateHistory, projectUpdateStateExpected, ProjectUpdateState.Returned); }
private static void AssertGetLatestForTransitionReturnsCorrectly(ProjectUpdateBatch projectUpdateBatch, ProjectUpdateHistory expectedProjectUpdateHistory, ProjectUpdateState projectUpdateStateExpected, ProjectUpdateState projectUpdateStateToCheck) { if (projectUpdateStateExpected == projectUpdateStateToCheck) { Assert.That(projectUpdateBatch.ProjectUpdateHistories.GetLatestProjectUpdateHistory(projectUpdateStateToCheck), Is.EqualTo(expectedProjectUpdateHistory), "Should have gotten the latest one in this transition"); } else { var latestProjectUpdateHistory = projectUpdateBatch.ProjectUpdateHistories.GetLatestProjectUpdateHistory(); Assert.That(latestProjectUpdateHistory.ProjectUpdateState, Is.Not.EqualTo(projectUpdateStateToCheck), "Should not return a ProjectUpdateHistory in this transition"); } }