public void GivenIOpenSharepointSource(string p0) { var manageSharepointServerSource = ScenarioContext.Current.Get <SharepointServerSource>(Utils.ViewNameKey); var mockStudioUpdateManager = new Mock <ISharePointSourceModel>(); mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost"); var mockEventAggregator = new Mock <IEventAggregator>(); var mockExecutor = new Mock <IServer>(); var username = @"dev2\IntegrationTester"; var password = TestEnvironmentVariables.GetVar(username); var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition { Name = "Test", Server = $"http://{Depends.SharepointBackupServer}", AuthenticationType = AuthenticationType.Windows, UserName = "******", Password = password }; mockStudioUpdateManager.Setup(model => model.FetchSource(It.IsAny <Guid>())) .Returns(sharePointServiceSourceDefinition); var manageSharepointServerSourceViewModel = new SharepointServerSourceViewModel(mockStudioUpdateManager.Object, mockEventAggregator.Object, sharePointServiceSourceDefinition, new SynchronousAsyncWorker(), mockExecutor.Object); manageSharepointServerSource.DataContext = manageSharepointServerSourceViewModel; ScenarioContext.Current.Remove("viewModel"); ScenarioContext.Current.Add("viewModel", manageSharepointServerSourceViewModel); }
public void Cleanup() { var mockExecutor = new Mock <IServer>(); var mockUpdateManager = ScenarioContext.Current.Get <Mock <ISharePointSourceModel> >("updateManager"); var mockRequestServiceNameViewModel = ScenarioContext.Current.Get <Mock <IRequestServiceNameViewModel> >("requestServiceNameViewModel"); var mockEventAggregator = new Mock <IEventAggregator>(); var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object); task.Start(); var viewModel = new SharepointServerSourceViewModel(mockUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker(), mockExecutor.Object); var manageWebserviceSourceControl = ScenarioContext.Current.Get <SharepointServerSource>(Utils.ViewNameKey); manageWebserviceSourceControl.DataContext = viewModel; FeatureContext.Current.Remove("viewModel"); FeatureContext.Current.Add("viewModel", viewModel); FeatureContext.Current.Remove("externalProcessExecutor"); FeatureContext.Current.Add("externalProcessExecutor", mockExecutor); }
public static void SetupForSystem() { Utils.SetupResourceDictionary(); var manageSharepointServerSource = new SharepointServerSource(); var mockStudioUpdateManager = new Mock <ISharePointSourceModel>(); var mockRequestServiceNameViewModel = new Mock <IRequestServiceNameViewModel>(); var mockEventAggregator = new Mock <IEventAggregator>(); var mockEnvironmentModel = new Mock <IServer>(); var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object); task.Start(); var manageSharepointServerSourceViewModel = new SharepointServerSourceViewModel(mockStudioUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker(), mockEnvironmentModel.Object); manageSharepointServerSource.DataContext = manageSharepointServerSourceViewModel; Utils.ShowTheViewForTesting(manageSharepointServerSource); FeatureContext.Current.Add(Utils.ViewNameKey, manageSharepointServerSource); FeatureContext.Current.Add(Utils.ViewModelNameKey, manageSharepointServerSourceViewModel); FeatureContext.Current.Add("updateManager", mockStudioUpdateManager); FeatureContext.Current.Add("requestServiceNameViewModel", mockRequestServiceNameViewModel); FeatureContext.Current.Add("mockEnvironmentModel", mockEnvironmentModel); }
public void TestInitialize() { _updateManagerMock = new Mock <ISharePointSourceModel>(); _aggregatorMock = new Mock <IEventAggregator>(); _asyncWorkerMock = new Mock <IAsyncWorker>(); _environmentMock = new Mock <IServer>(); _asyncWorkerMock.Setup( it => it.Start( It.IsAny <Action>(), It.IsAny <Action>(), It.IsAny <CancellationTokenSource>(), It.IsAny <Action <Exception> >())) .Callback <Action, Action, CancellationTokenSource, Action <Exception> >( (progress, success, token, errorAction) => { try { progress?.Invoke(); success?.Invoke(); } catch (Exception ex) { errorAction?.Invoke(ex); } }); _asyncWorkerMock.Setup( it => it.Start( It.IsAny <Func <List <ComputerName> > >(), It.IsAny <Action <List <ComputerName> > >(), It.IsAny <Action <Exception> >())) .Callback <Func <List <ComputerName> >, Action <List <ComputerName> >, Action <Exception> >( (progress, success, errorAction) => { try { success?.Invoke(progress?.Invoke()); } catch (Exception ex) { errorAction?.Invoke(ex); } }); _sharepointServerSourceMock = new Mock <ISharepointServerSource>(); _sharepointServerSourceMock.Setup(it => it.Name).Returns("someService"); _requestServiceNameViewModelMock = new Mock <IRequestServiceNameViewModel>(); _requestServiceNameViewModelTask = Task.FromResult(_requestServiceNameViewModelMock.Object); _updateManagerMock.Setup(model => model.FetchSource(It.IsAny <Guid>())) .Returns(_sharepointServerSourceMock.Object); _asyncWorkerMock.Setup(worker => worker.Start( It.IsAny <Func <ISharepointServerSource> >(), It.IsAny <Action <ISharepointServerSource> >())) .Callback <Func <ISharepointServerSource>, Action <ISharepointServerSource> >((func, action) => { var dbSource = func.Invoke(); action?.Invoke(dbSource); }); _changedProperties = new List <string>(); _target = new SharepointServerSourceViewModel( _updateManagerMock.Object, _aggregatorMock.Object, _asyncWorkerMock.Object, _environmentMock.Object); _target.PropertyChanged += (sender, args) => { _changedProperties.Add(args.PropertyName); }; _changedPropertiesSource = new List <string>(); _targetSource = new SharepointServerSourceViewModel( _updateManagerMock.Object, _aggregatorMock.Object, _sharepointServerSourceMock.Object, _asyncWorkerMock.Object, _environmentMock.Object); _targetSource.PropertyChanged += (sender, args) => { _changedPropertiesSource.Add(args.PropertyName); }; _changedPropertiesRequestServiceViewModel = new List <string>(); _targetRequestServiceViewModel = new SharepointServerSourceViewModel( _updateManagerMock.Object, _requestServiceNameViewModelTask, _aggregatorMock.Object, _asyncWorkerMock.Object, _environmentMock.Object); _targetRequestServiceViewModel.PropertyChanged += (sender, args) => { _changedPropertiesRequestServiceViewModel.Add(args.PropertyName); }; }