public static async Task BeforeTestRun() { AzureStorageEmulatorManager.StartStorageEmulator(); _container = IoC.Initialize(); await StartNServiceBusEndpoint(); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { // Do not access the form's BackgroundWorker reference directly. // Instead, use the reference provided by the sender parameter. if (!(sender is BackgroundWorker bw)) { throw new ArgumentException("Background Worker is Null"); } if (!(e.Argument is IList <object> args) || args.Count < 3) { throw new ArgumentException("Background Worker should have three arguments"); } if (!(args[0] is IEnumerable <string> allServiceConfigs)) { throw new ArgumentException("List of Service Config is null"); } if (!(args[1] is string operationName)) { throw new ArgumentException("background operation name is null"); } if (!(args[2] is bool startLocalAzureEmulator)) { throw new ArgumentException("Start Local Azure Emulator is Null"); } if (!_isServiceFabricStarted) { StartServiceFabric(); } foreach (var serviceConfig in allServiceConfigs) { var packagePublisher = new PackagePublisher(); var solutionPath = Directory.GetParent(serviceConfig) .Parent?.FullName; switch (operationName) { case "Install": packagePublisher.PublishPackage(solutionPath, ConfigToUpdate.Text, VSCommandLinePath.Text, update => { bw.ReportProgress(0, update); }); break; case "Uninstall": packagePublisher.UnInstallServiceFabricApp(solutionPath, update => { bw.ReportProgress(0, update); }); break; } bw.ReportProgress(1); } if (startLocalAzureEmulator) { AzureStorageEmulatorManager.StartStorageEmulator(); } }
public void Should_return_started_status() { if (AzureStorageEmulatorManager.IsProcessRunning()) { AzureStorageEmulatorManager.StopStorageEmulator(); Assert.That(AzureStorageEmulatorManager.IsProcessRunning(), Is.False); } AzureStorageEmulatorManager.StartStorageEmulator(); Assert.That(AzureStorageEmulatorManager.IsProcessRunning(), Is.True); }
private void StopStorageEmulatorIfRunning() { if (ConfigurationManager.AppSettings["IsLocalTestingEnvironment"].Equals("false")) { return; } if (AzureStorageEmulatorManager.IsProcessRunning()) { AzureStorageEmulatorManager.StopStorageEmulator(); } }
public static void StopAzureAfterAllTestsIfWasDown() { if (!_wasUp) { AzureStorageEmulatorManager.StopStorageEmulator(); } else { // Leave as it was before testing... } }
public static void StartAzureBeforeAllTestsIfNotUp(TestContext context) { if (!AzureStorageEmulatorManager.IsProcessStarted()) { AzureStorageEmulatorManager.StartStorageEmulator(); _wasUp = false; } else { _wasUp = true; } }
public static void StartLocalAzureStorageEmulator() { if (ConfigurationManager.AppSettings["IsLocalTestingEnvironment"].Equals("true")) { if (!AzureStorageEmulatorManager.IsProcessRunning()) { AzureStorageEmulatorManager.StartStorageEmulator(); } AzureStorageEmulatorManager.SetupImageContainer(); } }
public void StopStorageEmulator_WhenRunning_EmulatorShouldBeStopped() { if (ConfigurationManager.AppSettings["IsLocalTestingEnvironment"].Equals("false")) { return; } if (!AzureStorageEmulatorManager.IsProcessRunning()) { AzureStorageEmulatorManager.StartStorageEmulator(); AzureStorageEmulatorManager.IsProcessRunning().Should().BeTrue(); } AzureStorageEmulatorManager.StopStorageEmulator(); AzureStorageEmulatorManager.IsProcessRunning().Should().BeFalse(); }
public AzureStorageTestFixture() { var connectionString = Environment.GetEnvironmentVariable("AZURE_STORAGE_ACCOUNT_CONNECTION_STRING"); #if DEBUG if (string.IsNullOrEmpty(connectionString)) { _useDevelopmentStorageAccount = true; // Fallback to using the Azure Storage emulator if we didn't find a connection // string in the relevant environment variable. This should only be the case // at development time. CI builds will set this environment variable. // Note that the Azure Storage Emulator does not yet support Azure File Storage, // so Azure File Storage tests will fail if running with the emulator. _storageAccount = CloudStorageAccount.DevelopmentStorageAccount; // Here we attempt to auto-start the storage emulator if we're using // the development storage account. _azureStorageEmulatorManager = AzureStorageEmulatorManager.Instance; // If the storage emulator is already running, record this so // that we don't attempt stop the emulator when being disposed. _emulatorAlreadyRunning = _azureStorageEmulatorManager.GetIsEmulatorRunning() .GetAwaiter() .GetResult(); // TODO If this method is called twice, then the emulator won't be stopped as part of `Dispose`. // Also, consider what to do if multiple instances of this class are used simultaneously. if (!_emulatorAlreadyRunning) { // TODO There is a potential for a race-condition here. // Can we do anything about this? Perhaps we should remove // the above check, and just try to start the emulator. If it // is already started, then we can handle the exception that // is thrown and check at that point whether the emulator is // running. This yields the opposite race condition, but this // might be the case to optimise for. _azureStorageEmulatorManager.Start() .GetAwaiter() .GetResult(); } return; } #endif _storageAccount = CloudStorageAccount.Parse(connectionString); }
public void SetUp() { MigrateDbToLatestVersion(); Seed(); if (ConfigurationManager.AppSettings["IsLocalTestingEnvironment"].Equals("true")) { if (!AzureStorageEmulatorManager.IsProcessRunning()) { AzureStorageEmulatorManager.StartStorageEmulator(); } AzureStorageEmulatorManager.SetupImageContainer(); } }
public void RunBeforeAnyTests() { AzureStorageEmulatorManager.StartStorageEmulator(); }
public async Task Start() { var startUp = new Startup(); var hostBuilder = new HostBuilder() .ConfigureHostConfiguration(a => { a.Sources.Clear(); a.AddInMemoryCollection(_hostConfig); }) .ConfigureAppConfiguration(a => { a.Sources.Clear(); a.AddInMemoryCollection(_appConfig); a.SetBasePath(_testMessageBus.StorageDirectory.FullName); }) .ConfigureWebJobs(startUp.Configure) ; _ = hostBuilder.ConfigureServices((s) => { s.Configure <Config.EmployerIncentivesApiOptions>(a => { a.ApiBaseUrl = _testEmployerIncentivesApi.BaseAddress; a.SubscriptionKey = ""; }); _ = s.AddNServiceBus(new LoggerFactory().CreateLogger <TestLegalEntitiesFunctions>(), (o) => { o.EndpointConfiguration = (endpoint) => { endpoint.UseTransport <LearningTransport>().StorageDirectory(_testMessageBus.StorageDirectory.FullName); return(endpoint); }; var hook = _messageHooks.SingleOrDefault(h => h is Hook <MessageContext>) as Hook <MessageContext>; if (hook != null) { o.OnMessageReceived = (message) => { hook?.OnReceived(message); }; o.OnMessageProcessed = (message) => { hook?.OnProcessed(message); }; o.OnMessageErrored = (exception, message) => { hook?.OnErrored(exception, message); }; } }); }); hostBuilder.UseEnvironment("LOCAL"); host = await hostBuilder.StartAsync(); // ideally use the test server but no functions support yet. HttpTriggerRefreshLegalEntities = new HandleRefreshLegalEntitiesRequest(host.Services.GetService(typeof(ILegalEntitiesService)) as ILegalEntitiesService); TimerTriggerRefreshVendorRegistrationCaseStatus = new RefreshVendorRegistrationCaseStatus(host.Services.GetService(typeof(IVrfCaseRefreshService)) as IVrfCaseRefreshService); TimerTriggerEarningsResilienceCheck = new HandleEarningsResilienceCheck(host.Services.GetService(typeof(IEarningsResilienceCheckService)) as IEarningsResilienceCheckService); TimerTriggerBankDetailsRepeatReminderEmails = new HandleBankDetailsRepeatReminderEmails(host.Services.GetService(typeof(IEmailService)) as IEmailService, host.Services.GetService(typeof(IConfiguration)) as IConfiguration); HttpTriggerUpdateCollectionCalendarPeriod = new HandleUpdateCollectionCalendarPeriod(host.Services.GetService(typeof(ICollectionCalendarService)) as ICollectionCalendarService); HttpTriggerHandleWithdrawal = new HandleWithdrawalRequest(host.Services.GetService(typeof(IWithdrawalService)) as IWithdrawalService); HttpTriggerHandlePausePayments = new HandlePausePaymentsRequest(host.Services.GetService(typeof(IPausePaymentsService)) as IPausePaymentsService); AzureStorageEmulatorManager.StartStorageEmulator(); // only works if emulator sits here: "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" }
public static void CleanUp() { AzureStorageEmulatorManager.Stop(); }
public static void Initialize(TestContext context) { AzureStorageEmulatorManager.Start(); LogManager.Connect(); }
public void Setup() { AzureStorageEmulatorManager.StartStorageEmulator(); BuildWireMockClient(); BuildWireMockHost(); }