private void Dispose(bool disposing) { if (!mIsDisposed) { if (disposing) { StopFulfillingFiveYearPlanAsync() .Wait(); mEngine?.Dispose(); mEngine = null; mAppMetricsMonitor = null; mDbAssetFactory = null; IDisposable disposableAppMetricsMonitor = mAppMetricsMonitor as IDisposable; if (disposableAppMetricsMonitor != null) { disposableAppMetricsMonitor.Dispose(); } } mIsDisposed = true; } }
public async Task Test_CorrectlyWrapsErrorThrownBySetup() { Faker faker = new Faker(); Exception innerExc = faker.System.Exception(); StakhanoviseSetupException thrownSetupException = null; QueuedTaskMapping mapping = GetDefaultMapping(); ConnectionOptions connectionOptions = GenerateSetupTestDbConnectionOptions(); Mock <ISetupDbAsset> setupMockWithError = CreateDbAssetSetupMockWithError(innerExc); IList <ISetupDbAsset> dbAssetSetups = new List <ISetupDbAsset>(); dbAssetSetups.Add(setupMockWithError.Object); DbAssetFactory dbAssetFactory = new DbAssetFactory(dbAssetSetups, connectionOptions, mapping); try { await dbAssetFactory.CreateDbAssetsAsync(); } catch (StakhanoviseSetupException exc) { thrownSetupException = exc; } Assert.NotNull(thrownSetupException); Assert.AreSame(innerExc, thrownSetupException.InnerException); }
private async Task RunDbAssetFactoryTests(ConnectionOptions connectionOptions, QueuedTaskMapping mapping, int count) { List <Mock <ISetupDbAsset> > dbAssetSetupsMocks = CreateDbAssetSetupMocksWithoutError(connectionOptions, mapping, count); IList <ISetupDbAsset> dbAssetSetups = dbAssetSetupsMocks .Select(m => m.Object) .ToList(); DbAssetFactory factory = new DbAssetFactory(dbAssetSetups, connectionOptions, mapping); await factory.CreateDbAssetsAsync(); foreach (Mock <ISetupDbAsset> mock in dbAssetSetupsMocks) { mock.Verify(); mock.VerifyNoOtherCalls(); } }
public async Task <Stakhanovise> StartFulfillingFiveYearPlanAsync() { CheckNotDisposedOrThrow(); if (mDbAssetFactory == null) { mDbAssetFactory = mStakhanoviseSetup.BuildDbAssetFactory(); } if (mEngine == null) { mEngine = mStakhanoviseSetup.BuildTaskEngine(); } if (mAppMetricsMonitor == null) { mAppMetricsMonitor = mStakhanoviseSetup.BuildAppMetricsMonitor(); } if (mDbAssetFactory != null) { await mDbAssetFactory.CreateDbAssetsAsync(); } if (!mEngine.IsRunning) { await mEngine.StartAsync(); } if (mAppMetricsMonitor != null && !mAppMetricsMonitor.IsRunning && mEngine is IAppMetricsProvider) { await mAppMetricsMonitor.StartAsync(( IAppMetricsProvider )mEngine); } return(this); }