public static void SetupForSystem() { Utils.SetupResourceDictionary(); var manageDatabaseSourceControl = new ManageDatabaseSourceControl(); var mockStudioUpdateManager = new Mock <IManageDatabaseSourceModel>(); mockStudioUpdateManager.Setup(model => model.GetComputerNames()).Returns(new List <string> { "TEST", "RSAKLFSVRDEV", "RSAKLFSVRPDC", "RSAKLFSVRTFSBLD", "RSAKLFSVRWRWBLD" }); mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost"); var mockRequestServiceNameViewModel = new Mock <IRequestServiceNameViewModel>(); var mockEventAggregator = new Mock <IEventAggregator>(); var mockExecutor = new Mock <IExternalProcessExecutor>(); var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object); task.Start(); var manageDatabaseSourceViewModel = new ManageMySqlSourceViewModel(mockStudioUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker()); manageDatabaseSourceControl.DataContext = manageDatabaseSourceViewModel; Utils.ShowTheViewForTesting(manageDatabaseSourceControl); FeatureContext.Current.Add(Utils.ViewNameKey, manageDatabaseSourceControl); FeatureContext.Current.Add(Utils.ViewModelNameKey, manageDatabaseSourceViewModel); FeatureContext.Current.Add("updateManager", mockStudioUpdateManager); FeatureContext.Current.Add("requestServiceNameViewModel", mockRequestServiceNameViewModel); FeatureContext.Current.Add("externalProcessExecutor", mockExecutor); }
static void DisposeResources() { var mockUpdateManager = ScenarioContext.Current.Get <Mock <IManageDatabaseSourceModel> >("updateManager"); var mockRequestServiceNameViewModel = ScenarioContext.Current.Get <Mock <IRequestServiceNameViewModel> >("requestServiceNameViewModel"); var mockEventAggregator = new Mock <IEventAggregator>(); if (mockRequestServiceNameViewModel != null && mockUpdateManager != null) { var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object); task.Start(); var viewModel = new ManageMySqlSourceViewModel(mockUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker()); var manageDatabaseSourceControl = ScenarioContext.Current.Get <ManageDatabaseSourceControl>(Utils.ViewNameKey); if (manageDatabaseSourceControl != null) { if (manageDatabaseSourceControl.DataContext is ManageMySqlSourceViewModel manageDatabaseSourceViewModel) { Utils.ResetViewModel <ManageMySqlSourceViewModel, IDbSource>(viewModel, manageDatabaseSourceViewModel); manageDatabaseSourceViewModel.AuthenticationType = AuthenticationType.Windows; manageDatabaseSourceViewModel.DatabaseName = null; } } } }
public void GivenIOpen(string name) { var manageDatabaseSourceControl = ScenarioContext.Current.Get <ManageDatabaseSourceControl>(Utils.ViewNameKey); var upd = FeatureContext.Current.Get <Mock <IManageDatabaseSourceModel> >("updateManager").Object; var dbsrc = new DbSourceDefinition { Name = name, Id = Guid.NewGuid(), ServerName = "RSAKLFSVRDEV", AuthenticationType = AuthenticationType.Windows }; FeatureContext.Current["dbsrc"] = dbsrc; var mockEventAggregator = new Mock <IEventAggregator>(); var viewModel = new ManageMySqlSourceViewModel(upd, mockEventAggregator.Object, dbsrc, new SynchronousAsyncWorker()); var manageDatabaseSourceViewModel = manageDatabaseSourceControl.DataContext as ManageMySqlSourceViewModel; if (manageDatabaseSourceViewModel != null) { Utils.ResetViewModel <ManageMySqlSourceViewModel, IDbSource>(viewModel, manageDatabaseSourceViewModel); } }