Exemple #1
0
        public static void SetupForSystem()
        {
            Core.Utils.SetupResourceDictionary();
            var manageServerControl     = new ManageServerControl();
            var mockStudioUpdateManager = new Mock <IManageServerSourceModel>();

            mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost");
            mockStudioUpdateManager.Setup(model => model.GetComputerNames()).Returns(new List <string> {
                "rsaklfhuggspc", "barney", "SANDBOX-1"
            });
            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 manageServerSourceViewModel = new ManageNewServerViewModel(mockStudioUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker(), mockExecutor.Object);

            manageServerControl.DataContext = manageServerSourceViewModel;
            Core.Utils.ShowTheViewForTesting(manageServerControl);
            FeatureContext.Current.Add(Core.Utils.ViewNameKey, manageServerControl);
            FeatureContext.Current.Add("updateManager", mockStudioUpdateManager);
            FeatureContext.Current.Add("requestServiceNameViewModel", mockRequestServiceNameViewModel);
            FeatureContext.Current.Add("externalProcessExecutor", mockExecutor);
            FeatureContext.Current.Add("manageServerSourceViewModel", manageServerSourceViewModel);
        }
Exemple #2
0
        public void Cleanup()
        {
            var mockExecutor      = new Mock <IExternalProcessExecutor>();
            var mockUpdateManager = ScenarioContext.Current.Get <Mock <IManageServerSourceModel> >("updateManager");

            mockUpdateManager.Setup(model => model.ServerName).Returns("localhost");
            mockUpdateManager.Setup(model => model.GetComputerNames()).Returns(new List <string> {
                "rsaklfhuggspc", "barney", "SANDBOX-1"
            });
            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 ManageNewServerViewModel(mockUpdateManager.Object, task, mockEventAggregator.Object, new SynchronousAsyncWorker(), mockExecutor.Object);
            var manageServerControl = ScenarioContext.Current.Get <ManageServerControl>(Core.Utils.ViewNameKey);
            var originalViewModel   = GetViewModel(manageServerControl);

            manageServerControl.EnterPassword(viewModel.Password);
            manageServerControl.EnterUserName(viewModel.UserName);
            manageServerControl.SetPort(viewModel.SelectedPort);
            manageServerControl.SetProtocol(viewModel.Protocol);
            manageServerControl.SetAuthenticationType(viewModel.AuthenticationType);
            manageServerControl.EnterServerName(viewModel.ServerName.Name);
            originalViewModel.Password           = viewModel.Password;
            originalViewModel.UserName           = viewModel.UserName;
            originalViewModel.Protocol           = viewModel.Protocol;
            originalViewModel.AuthenticationType = viewModel.AuthenticationType;
            originalViewModel.ServerName         = viewModel.ServerName;

            FeatureContext.Current.Remove("externalProcessExecutor");
            FeatureContext.Current.Add("externalProcessExecutor", mockExecutor);
        }
Exemple #3
0
        public void GivenIOpenServerSource(string editingServerSource)
        {
            var manageServerControl     = ScenarioContext.Current.Get <ManageServerControl>(Core.Utils.ViewNameKey);
            var mockStudioUpdateManager = new Mock <IManageServerSourceModel>();

            mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost");
            mockStudioUpdateManager.Setup(model => model.GetComputerNames()).Returns(new List <string> {
                "rsaklfhuggspc", "barney", "SANDBOX-1"
            });
            var mockEventAggregator = new Mock <IEventAggregator>();
            var mockExecutor        = new Mock <IExternalProcessExecutor>();

            var username = @"dev2\IntegrationTester";
            var password = TestEnvironmentVariables.GetVar(username);

            var serverSourceDefinition = new Dev2.Common.ServerSource
            {
                Name               = "ServerSource",
                Address            = "https://SANDBOX-1:3143",
                ServerName         = "SANDBOX-1",
                AuthenticationType = AuthenticationType.User,
                UserName           = "******",
                Password           = password
            };
            var externalServerSourceDefinition = new Dev2.Common.ServerSource
            {
                Name               = "TestWarewolf",
                Address            = "http://test-warewolf.cloudapp.net:3142",
                ServerName         = "test-warewolf.cloudapp.net",
                AuthenticationType = AuthenticationType.Public
            };

            Dev2.Common.ServerSource serverSource;

            switch (editingServerSource)
            {
            case "ServerSource":
                serverSource = serverSourceDefinition;
                break;

            case "TestWarewolf":
                serverSource = externalServerSourceDefinition;
                break;

            default:
                serverSource = serverSourceDefinition;
                break;
            }


            mockStudioUpdateManager.Setup(model => model.FetchSource(It.IsAny <Guid>()))
            .Returns(serverSource);
            FeatureContext.Current["svrsrc"] = serverSource;
            var viewModel = GetViewModel(manageServerControl);
            var manageServerSourceViewModel = new ManageNewServerViewModel(mockStudioUpdateManager.Object, mockEventAggregator.Object, serverSource, new SynchronousAsyncWorker(), mockExecutor.Object);

            manageServerControl.EnterPassword(manageServerSourceViewModel.Password);
            manageServerControl.EnterUserName(manageServerSourceViewModel.UserName);
            manageServerControl.SetPort(manageServerSourceViewModel.SelectedPort);
            manageServerControl.SetProtocol(manageServerSourceViewModel.Protocol);
            manageServerControl.SetAuthenticationType(manageServerSourceViewModel.AuthenticationType);
            manageServerControl.EnterServerName(manageServerSourceViewModel.ServerName.Name);
            manageServerControl.SelectServer(manageServerSourceViewModel.ServerName.Name);
            viewModel.Password           = manageServerSourceViewModel.Password;
            viewModel.UserName           = manageServerSourceViewModel.UserName;
            viewModel.Protocol           = manageServerSourceViewModel.Protocol;
            viewModel.AuthenticationType = manageServerSourceViewModel.AuthenticationType;
            viewModel.ServerName         = manageServerSourceViewModel.ServerName;
            viewModel.Header             = manageServerSourceViewModel.Header;
            viewModel.HeaderText         = manageServerSourceViewModel.HeaderText;
            viewModel.Item = manageServerSourceViewModel.Item;
        }