/// <summary> /// Clean the Baseline progress status /// </summary> /// <param name="trainId">train id.</param> /// <returns>Error code if any</returns> public static ResultCodeEnum CleanTrainBaselineStatus(string trainId) { ResultCodeEnum resultCode = ResultCodeEnum.RequestAccepted; if (HistoryLoggerConfiguration.Used) { resultCode = HistoryLogger.CleanTrainBaselineStatus(trainId); } return(resultCode); }
public void TestUpdateTrainBaselineStatus() { // Test UpdateTrainBaselineStatus - Insert Guid id1 = Guid.NewGuid(); ResultCodeEnum error; error = HistoryLogger.UpdateTrainBaselineStatus("1", id1, 1, "TRAIN1", false, BaselineProgressStatusEnum.DEPLOYED, BaselineProgressStatusStateEnum.NONE, "1.1.1.1", "1.1.1.2", "1.1.1.3"); Assert.AreEqual(ResultCodeEnum.RequestAccepted, error); Guid id2 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("2", id2, 2, "TRAIN2", false, BaselineProgressStatusEnum.TRANSFER_COMPLETED, BaselineProgressStatusStateEnum.NONE, "2.1.1.1", "2.1.1.2", "2.1.1.3"); Assert.AreEqual(ResultCodeEnum.RequestAccepted, error); Guid id3 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("3", id3, 3, "TRAIN3", false, BaselineProgressStatusEnum.TRANSFER_PAUSED, BaselineProgressStatusStateEnum.NONE, "3.1.1.1", "3.1.1.2", "3.1.1.3"); Assert.AreEqual(ResultCodeEnum.RequestAccepted, error); Guid id4 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("4", id4, 4, "TRAIN4", false, BaselineProgressStatusEnum.UPDATED, BaselineProgressStatusStateEnum.NONE, "4.1.1.1", "4.1.1.2", "4.1.1.3"); Assert.AreEqual(ResultCodeEnum.RequestAccepted, error); Dictionary <string, TrainBaselineStatusData> dictionaryResponse; HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse["1"].TrainId, "1"); Assert.AreEqual(dictionaryResponse["1"].RequestId, id1); Assert.AreEqual(dictionaryResponse["1"].TaskId, 1); Assert.AreEqual(dictionaryResponse["1"].TrainNumber, "TRAIN1"); Assert.AreEqual(dictionaryResponse["1"].OnlineStatus, false); Assert.AreEqual(dictionaryResponse["1"].ProgressStatus, BaselineProgressStatusEnum.DEPLOYED); Assert.AreEqual(dictionaryResponse["1"].CurrentBaselineVersion, "1.1.1.1"); Assert.AreEqual(dictionaryResponse["1"].FutureBaselineVersion, "1.1.1.2"); Assert.AreEqual(dictionaryResponse["1"].PisOnBoardVersion, "1.1.1.3"); Assert.AreEqual(dictionaryResponse["2"].TrainId, "2"); Assert.AreEqual(dictionaryResponse["2"].RequestId, id2); Assert.AreEqual(dictionaryResponse["2"].TaskId, 2); Assert.AreEqual(dictionaryResponse["2"].TrainNumber, "TRAIN2"); Assert.AreEqual(dictionaryResponse["2"].OnlineStatus, false); Assert.AreEqual(dictionaryResponse["2"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_COMPLETED); Assert.AreEqual(dictionaryResponse["2"].CurrentBaselineVersion, "2.1.1.1"); Assert.AreEqual(dictionaryResponse["2"].FutureBaselineVersion, "2.1.1.2"); Assert.AreEqual(dictionaryResponse["2"].PisOnBoardVersion, "2.1.1.3"); Assert.AreEqual(dictionaryResponse["3"].TrainId, "3"); Assert.AreEqual(dictionaryResponse["3"].RequestId, id3); Assert.AreEqual(dictionaryResponse["3"].TaskId, 3); Assert.AreEqual(dictionaryResponse["3"].TrainNumber, "TRAIN3"); Assert.AreEqual(dictionaryResponse["3"].OnlineStatus, false); Assert.AreEqual(dictionaryResponse["3"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_PAUSED); Assert.AreEqual(dictionaryResponse["3"].CurrentBaselineVersion, "3.1.1.1"); Assert.AreEqual(dictionaryResponse["3"].FutureBaselineVersion, "3.1.1.2"); Assert.AreEqual(dictionaryResponse["3"].PisOnBoardVersion, "3.1.1.3"); Assert.AreEqual(dictionaryResponse["4"].TrainId, "4"); Assert.AreEqual(dictionaryResponse["4"].RequestId, id4); Assert.AreEqual(dictionaryResponse["4"].TaskId, 4); Assert.AreEqual(dictionaryResponse["4"].TrainNumber, "TRAIN4"); Assert.AreEqual(dictionaryResponse["4"].OnlineStatus, false); Assert.AreEqual(dictionaryResponse["4"].ProgressStatus, BaselineProgressStatusEnum.UPDATED); Assert.AreEqual(dictionaryResponse["4"].CurrentBaselineVersion, "4.1.1.1"); Assert.AreEqual(dictionaryResponse["4"].FutureBaselineVersion, "4.1.1.2"); Assert.AreEqual(dictionaryResponse["4"].PisOnBoardVersion, "4.1.1.3"); // Test UpdateTrainBaselineStatus - Update id1 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("1", id1, 5, "TRAIN1-1", true, BaselineProgressStatusEnum.TRANSFER_COMPLETED, BaselineProgressStatusStateEnum.NONE, "11.1.1.1", "11.1.1.2", "11.1.1.3"); Assert.AreEqual(error, ResultCodeEnum.RequestAccepted); id2 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("2", id2, 6, "TRAIN2-2", true, BaselineProgressStatusEnum.DEPLOYED, BaselineProgressStatusStateEnum.NONE, "22.1.1.1", "22.1.1.2", "22.1.1.3"); Assert.AreEqual(error, ResultCodeEnum.RequestAccepted); id3 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("3", id3, 7, "TRAIN3-3", true, BaselineProgressStatusEnum.TRANSFER_PLANNED, BaselineProgressStatusStateEnum.NONE, "33.1.1.1", "33.1.1.2", "33.1.1.3"); Assert.AreEqual(error, ResultCodeEnum.RequestAccepted); id4 = Guid.NewGuid(); error = HistoryLogger.UpdateTrainBaselineStatus("4", id4, 8, "TRAIN4-4", true, BaselineProgressStatusEnum.TRANSFER_IN_PROGRESS, BaselineProgressStatusStateEnum.NONE, "44.1.1.1", "44.1.1.2", "44.1.1.3"); Assert.AreEqual(error, ResultCodeEnum.RequestAccepted); HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse["1"].TrainId, "1"); Assert.AreEqual(dictionaryResponse["1"].RequestId, id1); Assert.AreEqual(dictionaryResponse["1"].TaskId, 5); Assert.AreEqual(dictionaryResponse["1"].TrainNumber, "TRAIN1-1"); Assert.AreEqual(dictionaryResponse["1"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["1"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_COMPLETED); Assert.AreEqual(dictionaryResponse["1"].CurrentBaselineVersion, "11.1.1.1"); Assert.AreEqual(dictionaryResponse["1"].FutureBaselineVersion, "11.1.1.2"); Assert.AreEqual(dictionaryResponse["1"].PisOnBoardVersion, "11.1.1.3"); Assert.AreEqual(dictionaryResponse["2"].TrainId, "2"); Assert.AreEqual(dictionaryResponse["2"].RequestId, id2); Assert.AreEqual(dictionaryResponse["2"].TaskId, 6); Assert.AreEqual(dictionaryResponse["2"].TrainNumber, "TRAIN2-2"); Assert.AreEqual(dictionaryResponse["2"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["2"].ProgressStatus, BaselineProgressStatusEnum.DEPLOYED); Assert.AreEqual(dictionaryResponse["2"].CurrentBaselineVersion, "22.1.1.1"); Assert.AreEqual(dictionaryResponse["2"].FutureBaselineVersion, "22.1.1.2"); Assert.AreEqual(dictionaryResponse["2"].PisOnBoardVersion, "22.1.1.3"); Assert.AreEqual(dictionaryResponse["3"].TrainId, "3"); Assert.AreEqual(dictionaryResponse["3"].RequestId, id3); Assert.AreEqual(dictionaryResponse["3"].TaskId, 7); Assert.AreEqual(dictionaryResponse["3"].TrainNumber, "TRAIN3-3"); Assert.AreEqual(dictionaryResponse["3"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["3"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_PLANNED); Assert.AreEqual(dictionaryResponse["3"].CurrentBaselineVersion, "33.1.1.1"); Assert.AreEqual(dictionaryResponse["3"].FutureBaselineVersion, "33.1.1.2"); Assert.AreEqual(dictionaryResponse["3"].PisOnBoardVersion, "33.1.1.3"); Assert.AreEqual(dictionaryResponse["4"].TrainId, "4"); Assert.AreEqual(dictionaryResponse["4"].RequestId, id4); Assert.AreEqual(dictionaryResponse["4"].TaskId, 8); Assert.AreEqual(dictionaryResponse["4"].TrainNumber, "TRAIN4-4"); Assert.AreEqual(dictionaryResponse["4"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["4"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_IN_PROGRESS); Assert.AreEqual(dictionaryResponse["4"].CurrentBaselineVersion, "44.1.1.1"); Assert.AreEqual(dictionaryResponse["4"].FutureBaselineVersion, "44.1.1.2"); Assert.AreEqual(dictionaryResponse["4"].PisOnBoardVersion, "44.1.1.3"); HistoryLogger.GetTrainBaselineStatusByProgressStatus(BaselineProgressStatusEnum.TRANSFER_COMPLETED, out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("1"), true); Assert.AreEqual(dictionaryResponse.Count, 1); // Checking the train id 1 Assert.AreEqual(dictionaryResponse["1"].TrainId, "1"); Assert.AreEqual(dictionaryResponse["1"].RequestId, id1); Assert.AreEqual(dictionaryResponse["1"].TaskId, 5); Assert.AreEqual(dictionaryResponse["1"].TrainNumber, "TRAIN1-1"); Assert.AreEqual(dictionaryResponse["1"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["1"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_COMPLETED); Assert.AreEqual(dictionaryResponse["1"].CurrentBaselineVersion, "11.1.1.1"); Assert.AreEqual(dictionaryResponse["1"].FutureBaselineVersion, "11.1.1.2"); Assert.AreEqual(dictionaryResponse["1"].PisOnBoardVersion, "11.1.1.3"); //Test GetTrainBaselineStatusByProgressStatus HistoryLogger.GetTrainBaselineStatusByProgressStatus(BaselineProgressStatusEnum.DEPLOYED, out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("2"), true); Assert.AreEqual(dictionaryResponse.Count, 1); Assert.AreEqual(dictionaryResponse["2"].TrainId, "2"); Assert.AreEqual(dictionaryResponse["2"].RequestId, id2); Assert.AreEqual(dictionaryResponse["2"].TaskId, 6); Assert.AreEqual(dictionaryResponse["2"].TrainNumber, "TRAIN2-2"); Assert.AreEqual(dictionaryResponse["2"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["2"].ProgressStatus, BaselineProgressStatusEnum.DEPLOYED); Assert.AreEqual(dictionaryResponse["2"].CurrentBaselineVersion, "22.1.1.1"); Assert.AreEqual(dictionaryResponse["2"].FutureBaselineVersion, "22.1.1.2"); Assert.AreEqual(dictionaryResponse["2"].PisOnBoardVersion, "22.1.1.3"); HistoryLogger.GetTrainBaselineStatusByProgressStatus(BaselineProgressStatusEnum.TRANSFER_PLANNED, out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("3"), true); Assert.AreEqual(dictionaryResponse.Count, 1); Assert.AreEqual(dictionaryResponse["3"].TrainId, "3"); Assert.AreEqual(dictionaryResponse["3"].RequestId, id3); Assert.AreEqual(dictionaryResponse["3"].TaskId, 7); Assert.AreEqual(dictionaryResponse["3"].TrainNumber, "TRAIN3-3"); Assert.AreEqual(dictionaryResponse["3"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["3"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_PLANNED); Assert.AreEqual(dictionaryResponse["3"].CurrentBaselineVersion, "33.1.1.1"); Assert.AreEqual(dictionaryResponse["3"].FutureBaselineVersion, "33.1.1.2"); Assert.AreEqual(dictionaryResponse["3"].PisOnBoardVersion, "33.1.1.3"); HistoryLogger.GetTrainBaselineStatusByProgressStatus(BaselineProgressStatusEnum.TRANSFER_IN_PROGRESS, out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("4"), true); Assert.AreEqual(dictionaryResponse.Count, 1); Assert.AreEqual(dictionaryResponse["4"].TrainId, "4"); Assert.AreEqual(dictionaryResponse["4"].RequestId, id4); Assert.AreEqual(dictionaryResponse["4"].TaskId, 8); Assert.AreEqual(dictionaryResponse["4"].TrainNumber, "TRAIN4-4"); Assert.AreEqual(dictionaryResponse["4"].OnlineStatus, true); Assert.AreEqual(dictionaryResponse["4"].ProgressStatus, BaselineProgressStatusEnum.TRANSFER_IN_PROGRESS); Assert.AreEqual(dictionaryResponse["4"].CurrentBaselineVersion, "44.1.1.1"); Assert.AreEqual(dictionaryResponse["4"].FutureBaselineVersion, "44.1.1.2"); Assert.AreEqual(dictionaryResponse["4"].PisOnBoardVersion, "44.1.1.3"); // Test Delete HistoryLogger.CleanTrainBaselineStatus("1"); HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("1"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("2"), true); Assert.AreEqual(dictionaryResponse.ContainsKey("3"), true); Assert.AreEqual(dictionaryResponse.ContainsKey("4"), true); Assert.AreEqual(dictionaryResponse.Count, 3); HistoryLogger.CleanTrainBaselineStatus("2"); HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("1"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("2"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("3"), true); Assert.AreEqual(dictionaryResponse.ContainsKey("4"), true); Assert.AreEqual(dictionaryResponse.Count, 2); HistoryLogger.CleanTrainBaselineStatus("3"); HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse.ContainsKey("1"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("2"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("3"), false); Assert.AreEqual(dictionaryResponse.ContainsKey("4"), true); Assert.AreEqual(dictionaryResponse.Count, 1); HistoryLogger.CleanTrainBaselineStatus("4"); HistoryLogger.GetTrainBaselineStatus(out dictionaryResponse); Assert.AreEqual(dictionaryResponse.Count, 0); }