예제 #1
0
        protected override IEnumerable <TestRun> CreateRuns(IEnumerable <MethodInfo> tests)
        {
            var namespaceGroups = tests.GroupBy(t => t.ReflectedType.Namespace);

            return
                (from environment in Environments.Where(ns => ns.Namespaces != null)
                 let envTests =
                     namespaceGroups.Where(nsg => environment.Namespaces.Contains(nsg.Key)).SelectMany(nsg => nsg)
                     select new TestRun(environment, envTests.ToList()));
        }
예제 #2
0
        /// <summary>
        ///     Updates the worksapces for all environments
        /// </summary>
        public void UpdateWorkspaces(IConnectControlSingleton connectControlSingleton)
        {
            if (CircularProgressBarVisibility == Visibility.Visible)
            {
                return;
            }

            CircularProgressBarVisibility = Visibility.Visible;
            RefreshButtonVisibility       = Visibility.Hidden;

            var tmpSelected = SelectedItem;
            List <IExplorerItemModel> expandedList = new List <IExplorerItemModel>();
            List <Task> loadTasks    = new List <Task>();
            List <Guid> environments = new List <Guid>();

            foreach (var environment in Environments.Where(c => c.IsConnected || c.IsLocalHost))
            {
                var explorerItemModel = ExplorerItemModels.FirstOrDefault(c => c.EnvironmentId == environment.ID);
                if (explorerItemModel != null)
                {
                    expandedList = explorerItemModel.Descendants().Where(c => c.IsExplorerExpanded).ToList();
                }

                if (environment != null)
                {
                    environments.Add(environment.ID);
                    connectControlSingleton.SetConnectionState(environment.ID, ConnectionEnumerations.ConnectedState.Busy);
                    if (!environment.IsConnected)
                    {
                        var loadResourcesAsync = LoadResourcesAsync(environment, expandedList, tmpSelected);

                        if (loadResourcesAsync != null)
                        {
                            loadTasks.Add(loadResourcesAsync);
                        }
                    }
                    else
                    {
                        var taskref = TaskRefresh(connectControlSingleton, environment);
                        loadTasks.Add(taskref);
                    }
                }
            }

            var task = Task.WhenAll(loadTasks);

            task.ContinueWith(d =>
            {
                environments.ForEach(id => connectControlSingleton.SetConnectionState(id, ConnectionEnumerations.ConnectedState.Connected));
                CircularProgressBarVisibility = Visibility.Hidden;
                RefreshButtonVisibility       = Visibility.Visible;
            });
        }
        protected virtual async Task Refresh(bool refresh)
        {
            IsRefreshing = true;
            var environmentId         = ConnectControlViewModel?.SelectedConnection.EnvironmentID;
            var resourceName          = ConnectControlViewModel?.SelectedConnection.DisplayName.Replace("(Connected)", "").Trim();
            var environmentViewModels = Environments.Where(model => resourceName != null && model.Server.EnvironmentID == environmentId && model.Server.DisplayName.Replace("(Connected)", "").Trim() == resourceName);

            foreach (var environmentViewModel in environmentViewModels)
            {
                await RefreshEnvironment(environmentViewModel, refresh);
            }
            Environments = new ObservableCollection <IEnvironmentViewModel>(Environments);
            IsRefreshing = false;
        }
예제 #4
0
        void LoadEnvironments()
        {
            Environments.Clear();
            Environment.Fill(Environments);

            var env = Environments.Where(e => e.Id == Configuration.Instance.LocalSettings.LastEnvironmentId).FirstOrDefault();

            if (env != null)
            {
                EnvList.SelectedItem = env;
            }
            else
            {
                EnvList.SelectedIndex = 0;
            }
        }
        /// <inheritdoc />
        protected override bool CheckParameters()
        {
            // check Base-Parameters
            base.CheckParameters();

            if (Environments is null || !Environments.Any())
            {
                Output.WriteError($"no {nameof(Environments)} given -- see help for more information");
                return(false);
            }

            // if environment doesn't contain '/' or contains multiple of them...
            var errEnvironments = Environments.Where(e => !e.Contains('/') ||
                                                     e.IndexOf('/') != e.LastIndexOf('/'))
                                  .ToArray();

            // ... complain about them
            if (errEnvironments.Any())
            {
                Output.WriteError($"given environments contain errors: {string.Join("; ", errEnvironments)}");
                return(false);
            }

            // Structures may be null or empty - but if not, all entries need to be in correct format
            if (Structures?.Any() == true)
            {
                // if environment doesn't contain '/' or contains multiple of them...
                var errStructures = Structures.Where(s => !s.Contains('/') ||
                                                     s.IndexOf('/') != s.LastIndexOf('/'))
                                    .ToArray();

                // ... complain about them
                if (errStructures.Any())
                {
                    Output.WriteError($"given structures contain errors: {string.Join("; ", errStructures)}");
                    return(false);
                }
            }

            return(true);
        }
        /// <inheritdoc />
        protected override bool CheckParameters()
        {
            // check Base-Parameters
            if (!base.CheckParameters())
            {
                return(false);
            }

            if (Environments is null || !Environments.Any())
            {
                Output.WriteError($"no {nameof(Environments)} given -- see help for more information");
                return(false);
            }

            // if environment doesn't contain '/' or contains multiple of them...
            var errEnvironments = Environments.Where(e => !e.Contains('/') ||
                                                     e.IndexOf('/') != e.LastIndexOf('/'))
                                  .ToArray();

            // ... complain about them
            if (errEnvironments.Any())
            {
                Output.WriteError($"given environments contain errors: {string.Join("; ", errEnvironments)}");
                return(false);
            }

            // if UseInputEnvironment is given we have to check for the correct format
            if (!string.IsNullOrWhiteSpace(UseInputEnvironment) &&
                (!UseInputEnvironment.Contains('/') ||
                 UseInputEnvironment.IndexOf('/') != UseInputEnvironment.LastIndexOf('/')))
            {
                Output.WriteError("parameter '-u|--use-environment' is invalid, see 'compare --help' for the required format");
                return(false);
            }

            return(true);
        }
예제 #7
0
        protected override IEnumerable <MethodInfo> FilterTests(IEnumerable <MethodInfo> tests)
        {
            var namespaces = Environments.Where(env => env.Namespaces != null).SelectMany(env => env.Namespaces);

            return(tests.Where(test => namespaces.Any(ns => test.DeclaringType.Namespace.Contains(ns))));
        }
예제 #8
0
 /// <summary>
 /// Gets the environment by name.
 /// </summary>
 /// <param name="environmentName">Name of the environment.</param>
 /// <returns></returns>
 public IEnvironment GetEnvironmentByName(string environmentName)
 {
     return(Environments.Where(e => e.Name.Equals(environmentName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault());
 }