Esempio n. 1
0
        /// <summary>
        /// Note, the saving is done by the controller
        /// </summary>
        private static void CreateNewTransitionRecord(this ProjectUpdateBatch projectUpdateBatch, ProjectUpdateState projectUpdateState, FirmaSession currentFirmaSession, DateTime transitionDate)
        {
            var currentPerson        = currentFirmaSession.Person;
            var projectUpdateHistory = new ProjectUpdateHistory(projectUpdateBatch, projectUpdateState, currentPerson, transitionDate);

            HttpRequestStorage.DatabaseEntities.AllProjectUpdateHistories.Add(projectUpdateHistory);
            projectUpdateBatch.ProjectUpdateStateID = projectUpdateState.ProjectUpdateStateID;
            projectUpdateBatch.TickleLastUpdateDate(transitionDate, currentFirmaSession);
        }
 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");
     }
 }
 public static void DeleteProjectUpdateHistory(this IQueryable <ProjectUpdateHistory> projectUpdateHistories, ProjectUpdateHistory projectUpdateHistoryToDelete)
 {
     DeleteProjectUpdateHistory(projectUpdateHistories, new List <ProjectUpdateHistory> {
         projectUpdateHistoryToDelete
     });
 }