/// <summary> /// Initializes the data package service. /// </summary> /// <param name="isRestart">Parameter that indicates if it is a restart simulation of the services.</param> protected void InitializeDataPackageService(bool isRestart) { Assert.IsTrue(HistoryLoggerConfiguration.Used, "The test application is misconfigured. HistoryLoggerConfiguration.Used is not set to proper value"); Assert.IsTrue(HistoryLoggerConfiguration.Valid, "The test application is misconfigured. HistoryLoggerConfiguration.Valid is not set to proper value"); // Create a complete T2G Manager _t2gManager = T2GManagerContainer.T2GManager; _sessionManager = new SessionManager(); _baselineStatusUpdater = new BaselineStatusUpdater(); if (!isRestart) { Assert.IsEmpty(_sessionManager.RemoveAllSessions(), "Cannot empty the session database"); } _requestFactory = new RequestContextFactory(_t2gManager, _remoteDataStoreFactoryMock.Object, _baselineStatusUpdater); _requestManager = new RequestManager(); _datapackageServiceStub = new DataPackageServiceStub(_sessionManager, _notificationsSender, _t2gManager, _requestFactory, _remoteDataStoreFactoryMock.Object, _requestManager, _baselineStatusUpdater ); }
/// <summary> /// Stops the data package service. /// </summary> protected void StopDataPackageService() { if (_datapackageServiceStub != null) { _datapackageServiceStub.Dispose(); _datapackageServiceStub = null; } if (_requestManager != null) { _requestManager.Dispose(); _requestManager = null; } DataPackageService.Uninitialize(); if (_baselineStatusUpdater != null) { _baselineStatusUpdater.Dispose(); _baselineStatusUpdater = null; } if (_t2gManager != null) { _t2gManager.Dispose(); _t2gManager = null; } T2GManagerContainer.T2GManager = null; _sessionManager = null; _requestFactory = null; }
public void TearDown() { if (_datapackageServiceStub != null) { _datapackageServiceStub.Dispose(); _datapackageServiceStub = null; } if (_requestManager != null) { _requestManager.Dispose(); _requestManager = null; } foreach (ServiceHost service in new ServiceHost[] { _hostVehicleInfoService, _hostFileTransferService, _hostIdentificationService, _hostNotificationService, _hostTrainDataPackageService }) { if (service == null) { continue; } if (service.State == CommunicationState.Faulted) { service.Abort(); } service.Close(); } if (_vehicleInfoServiceStub != null) { _vehicleInfoServiceStub.Dispose(); } if (_baselineStatusUpdater != null) { _baselineStatusUpdater.Dispose(); } _hostIdentificationService = null; _hostFileTransferService = null; _hostVehicleInfoService = null; _hostNotificationService = null; _hostTrainDataPackageService = null; _fileTransferServiceStub = null; _identificationServiceStub = null; _vehicleInfoServiceStub = null; _notificationServiceStub = null; _trainDataPackageServiceStub = null; _baselineStatusUpdater = null; DataPackageService.Uninitialize(); T2GManagerContainer.T2GManager = null; _t2gManager = null; _sessionManager = null; _requestFactory = null; if (_dataStoreServiceStub != null) { _dataStoreServiceStub.Dispose(); _dataStoreServiceStub = null; } _remoteDataStoreFactoryMock = null; TestContext currentContext = TestContext.CurrentContext; Console.Out.WriteLine("==================================="); Console.Out.WriteLine("END TEST {0}", currentContext.Test.Name); Console.Out.WriteLine("==================================="); }