public void InitializeMissionInvalidMissionCode() { AvailableElementData elementData = null; Guid requestId = Guid.NewGuid(); MissionParams missionParams = InitMissionParams( this._sessionId, string.Empty, this._elementId, null, 1); this._sessionManagerMock.Setup(x => x.IsSessionValid(It.IsAny <Guid>())).Returns(true); this._sessionManagerMock.Setup(x => x.GenerateRequestID(It.IsAny <Guid>(), out requestId)).Returns(string.Empty); this._train2groundClientMock.Setup(y => y.GetAvailableElementDataByElementNumber(missionParams.ElementId, out elementData)).Returns(T2GManagerErrorEnum.eSuccess); MissionInitializeMissionResult result = this._missionService.InitializeMission( missionParams.SessionId, missionParams.MissionCode, missionParams.ElementId, missionParams.StationList, missionParams.Timeout); Assert.AreEqual(MissionServiceErrorCodeEnum.ErrorInvalidMissionCode, result.ResultCode); Assert.AreEqual(requestId, result.RequestId); Assert.IsNullOrEmpty(result.MissionCode); Assert.IsNull(result.InvalidStationList); }
public void InitializeMissionErrorOpeningLMTDb() { AvailableElementData elementData = InitTrainElement(); Guid requestId = Guid.NewGuid(); File.Copy(this._dbSourcePath, Path.Combine(this._dbWorkingPath, "file.db")); MissionParams missionParams = InitMissionParams( this._sessionId, this._existingMissionCode, this._elementId, null, 1); this._sessionManagerMock.Setup(x => x.IsSessionValid(It.IsAny <Guid>())).Returns(true); this._sessionManagerMock.Setup(x => x.GenerateRequestID(It.IsAny <Guid>(), out requestId)).Returns(string.Empty); this._train2groundClientMock.Setup(y => y.GetAvailableElementDataByElementNumber(missionParams.ElementId, out elementData)).Returns(T2GManagerErrorEnum.eSuccess); this._remoteDataStoreFactoryMock.Setup(z => z.GetRemoteDataStoreInstance()).Returns(new RemoteDataStoreSimulator.RemoteDataStore(this._dbWorkingPath, "1.1.1.1")); MissionInitializeMissionResult result = this._missionService.InitializeMission( missionParams.SessionId, missionParams.MissionCode, missionParams.ElementId, missionParams.StationList, missionParams.Timeout); Assert.AreEqual(MissionServiceErrorCodeEnum.ErrorOpeningLMTDb, result.ResultCode); Assert.AreEqual(result.RequestId, requestId); Assert.AreEqual(result.MissionCode, missionParams.MissionCode); }
public void InitializeMissionInvalidRequestTimeout() { AvailableElementData elementData = null; Guid requestId = Guid.NewGuid(); MissionParams missionParams = InitMissionParams( this._sessionId, this._existingMissionCode, this._elementId, null, 50000); MissionInitializeMissionResult result = this._missionService.InitializeMission( missionParams.SessionId, missionParams.MissionCode, missionParams.ElementId, missionParams.StationList, missionParams.Timeout); this._sessionManagerMock.Verify(a => a.IsSessionValid(It.IsAny <Guid>()), Times.Never()); this._sessionManagerMock.Verify(b => b.GenerateRequestID(It.IsAny <Guid>(), out requestId), Times.Never()); this._train2groundClientMock.Verify(c => c.GetAvailableElementDataByElementNumber(missionParams.ElementId, out elementData), Times.Never()); Assert.AreEqual(MissionServiceErrorCodeEnum.ErrorInvalidRequestTimeout, result.ResultCode); Assert.AreEqual(Guid.Empty, result.RequestId); Assert.AreEqual(result.MissionCode, missionParams.MissionCode); Assert.IsNull(result.InvalidStationList); }
public void InitializeMissionNewMissionRequestAccepted() { AvailableElementData elementData = InitTrainElement(); Guid requestId = Guid.NewGuid(); File.Copy(this._dbSourcePath, Path.Combine(this._dbWorkingPath, "file.db")); List <string> inputStationList = InitStationList(StationListTypeEnum.VALID_ONLY); MissionParams missionParams = InitMissionParams( this._sessionId, this._newMissionCode, this._elementId, inputStationList, 1); ServiceInfo serviceInfo = this.InitServiceInfo(); this._sessionManagerMock.Setup(x => x.IsSessionValid(It.IsAny <Guid>())).Returns(true); this._sessionManagerMock.Setup(x => x.GenerateRequestID(It.IsAny <Guid>(), out requestId)).Returns(string.Empty); this._train2groundClientMock.Setup(y => y.GetAvailableElementDataByElementNumber(missionParams.ElementId, out elementData)).Returns(T2GManagerErrorEnum.eSuccess); this._remoteDataStoreFactoryMock.Setup(z => z.GetRemoteDataStoreInstance()).Returns(new RemoteDataStoreSimulator.RemoteDataStore(this._dbWorkingPath, "3.0.13.0")); T2GManagerErrorEnum rslt = T2GManagerErrorEnum.eSuccess; this._train2groundClientMock.Setup(x => x.GetAvailableServiceData( missionParams.ElementId, (int)eServiceID.eSrvSIF_MissionServer, out serviceInfo)).Returns(rslt); MissionInitializeMissionResult result = this._missionService.InitializeMission( missionParams.SessionId, missionParams.MissionCode, missionParams.ElementId, missionParams.StationList, missionParams.Timeout); Assert.AreEqual(MissionServiceErrorCodeEnum.RequestAccepted, result.ResultCode); Assert.AreEqual(result.RequestId, requestId); Assert.AreEqual(result.MissionCode, this._newMissionCode); }