Example #1
0
        public void Cleanup()
        {
            var mockExecutor      = new Mock <IExternalProcessExecutor>();
            var mockUpdateManager = ScenarioContext.Current.Get <Mock <IRabbitMQSourceModel> >("updateManager");
            var mockRequestServiceNameViewModel = ScenarioContext.Current.Get <Mock <IRequestServiceNameViewModel> >("requestServiceNameViewModel");
            var task = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object);

            task.Start();
            var viewModel = new ManageRabbitMQSourceViewModel(mockUpdateManager.Object, task);
            var manageRabbitMqSourceControl = ScenarioContext.Current.Get <ManageRabbitMQSourceControl>(Utils.ViewNameKey);

            manageRabbitMqSourceControl.DataContext = viewModel;
            FeatureContext.Current.Remove("viewModel");
            FeatureContext.Current.Add("viewModel", viewModel);
            FeatureContext.Current.Remove("externalProcessExecutor");
            FeatureContext.Current.Add("externalProcessExecutor", mockExecutor);
        }
Example #2
0
        public static void SetupForSystem()
        {
            Utils.SetupResourceDictionary();
            var manageRabbitMqSourceControl     = new ManageRabbitMQSourceControl();
            var mockStudioUpdateManager         = new Mock <IRabbitMQSourceModel>();
            var mockRequestServiceNameViewModel = new Mock <IRequestServiceNameViewModel>();
            var mockExecutor = new Mock <IExternalProcessExecutor>();
            var task         = new Task <IRequestServiceNameViewModel>(() => mockRequestServiceNameViewModel.Object);

            task.Start();
            var manageRabbitMqSourceViewModel = new ManageRabbitMQSourceViewModel(mockStudioUpdateManager.Object, task);

            manageRabbitMqSourceControl.DataContext = manageRabbitMqSourceViewModel;
            Utils.ShowTheViewForTesting(manageRabbitMqSourceControl);
            FeatureContext.Current.Add(Utils.ViewNameKey, manageRabbitMqSourceControl);
            FeatureContext.Current.Add(Utils.ViewModelNameKey, manageRabbitMqSourceViewModel);
            FeatureContext.Current.Add("updateManager", mockStudioUpdateManager);
            FeatureContext.Current.Add("requestServiceNameViewModel", mockRequestServiceNameViewModel);
            FeatureContext.Current.Add("externalProcessExecutor", mockExecutor);
        }
 public void TestInitialize()
 {
     _rabbitMQSourceModel             = new Mock <IRabbitMQSourceModel>();
     _requestServiceNameViewModel     = new Mock <IRequestServiceNameViewModel>();
     _rabbitMQServiceSourceDefinition = new Mock <IRabbitMQServiceSourceDefinition>();
     _requestServiceNameViewModelTask = Task.FromResult(_requestServiceNameViewModel.Object);
     _changedProperties = new List <string>();
     _manageRabbitMQSourceViewModelWithTask = new ManageRabbitMQSourceViewModel(_rabbitMQSourceModel.Object, _requestServiceNameViewModelTask);
     _manageRabbitMQSourceViewModelWithTask.PropertyChanged += (sender, e) => { _changedProperties.Add(e.PropertyName); };
     _asyncWorkerMock = new Mock <IAsyncWorker>();
     _rabbitMQSourceModel.Setup(model => model.FetchSource(It.IsAny <Guid>()))
     .Returns(_rabbitMQServiceSourceDefinition.Object);
     _asyncWorkerMock.Setup(worker =>
                            worker.Start(
                                It.IsAny <Func <IRabbitMQServiceSourceDefinition> >(),
                                It.IsAny <Action <IRabbitMQServiceSourceDefinition> >()))
     .Callback <Func <IRabbitMQServiceSourceDefinition>, Action <IRabbitMQServiceSourceDefinition> >((func, action) =>
     {
         var dbSource = func.Invoke();
         action?.Invoke(dbSource);
     });
     _manageRabbitMQSourceViewModelWithRabbitMQServiceSourceDefinition = new ManageRabbitMQSourceViewModel(_rabbitMQSourceModel.Object, _rabbitMQServiceSourceDefinition.Object, _asyncWorkerMock.Object);
 }