public static void SetupForSystem() { Utils.SetupResourceDictionary(); var sourceControl = new ManagePluginSourceControl(); var pluginSourceModel = new Mock <IManagePluginSourceModel>(); pluginSourceModel.Setup(model => model.FetchSource(It.IsAny <Guid>())) .Returns(new PluginSourceDefinition() { Name = "Test", GACAssemblyName = "GAC:AuditPolicyGPManagedStubs, Version=6.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }); pluginSourceModel.Setup(model => model.ServerName).Returns("localhost"); pluginSourceModel.Setup(model => model.GetDllListings(null)).Returns(BuildBaseListing()); var mockRequestServiceNameViewModel = new Mock <IRequestServiceNameViewModel>(); var mockEventAggregator = new Mock <IEventAggregator>(); var mockExecutor = new Mock <IExternalProcessExecutor>(); var mockSynchronousAsyncWorker = new Mock <SynchronousAsyncWorker>(); var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object); task.Start(); var viewModel = new ManagePluginSourceViewModel(pluginSourceModel.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker()); sourceControl.DataContext = viewModel; Utils.ShowTheViewForTesting(sourceControl); FeatureContext.Current.Add(Utils.ViewNameKey, sourceControl); FeatureContext.Current.Add(Utils.ViewModelNameKey, viewModel); FeatureContext.Current.Add("updateManager", pluginSourceModel); FeatureContext.Current.Add("requestServiceNameViewModel", mockRequestServiceNameViewModel); FeatureContext.Current.Add("externalProcessExecutor", mockExecutor); FeatureContext.Current.Add("eventAggregator", mockEventAggregator); FeatureContext.Current.Add("synchronousAsyncWorker", mockSynchronousAsyncWorker); }
void SetTextBoxValue(ManagePluginSourceControl sourceControl, string controlName, string input) { switch (controlName) { case "AssemblyName": sourceControl.AssemblyNameTextBox.Text = input; var assem = sourceControl.AssemblyNameTextBox.GetBindingExpression(TextBlock.TextProperty); assem?.UpdateSource(); break; case "ConfigFile": sourceControl.ConfigFileTextbox.Text = input; var config = sourceControl.ConfigFileTextbox.GetBindingExpression(TextBlock.TextProperty); config?.UpdateSource(); break; case "GacAssemblyName": sourceControl.GacAssemblyNameTextBox.Text = input; var gac = sourceControl.GacAssemblyNameTextBox.GetBindingExpression(TextBlock.TextProperty); gac?.UpdateSource(); break; default: break; } }