예제 #1
0
        public static string FullMessage(ComparisonDifference difference, int maxDepth = 3, TestStatus minSeverity = TestStatus.Pass)
        {
            if (difference == null || !difference.Status.IsEqualOrMoreSevere(minSeverity))
            {
                return("");
            }

            string message = difference.Message + Environment.NewLine;

            message += $"Expected value: {difference.ReferenceValue}, returned value from execution: {difference.RunValue}";

            if (string.IsNullOrEmpty(difference.Property))
            {
                message += ".";
            }
            else
            {
                message += $", for the property {difference.Property} of the returned object.";
            }

            message += Environment.NewLine;

            return(message);
        }
예제 #2
0
        private static void ReloadGlux()
        {
            object   selectedObject = null;
            IElement parentElement  = null;

            PluginManager.ReceiveOutput("Reloading .glux");
            if (GlueState.Self.CurrentTreeNode != null)
            {
                selectedObject = GlueState.Self.CurrentTreeNode.Tag;
                if (selectedObject is NamedObjectSave)
                {
                    parentElement = ((NamedObjectSave)selectedObject).GetContainer();
                }
            }

            bool usingQuickReload = true;

            if (usingQuickReload)
            {
                GlueProjectSave newGlueProjectSave;
                CompareObjects  comparisonObject = ProjectManager.GlueProjectSave.ReloadUsingComparison(ProjectManager.GlueProjectFileName, out newGlueProjectSave);

                if (comparisonObject != null && comparisonObject.Differences.Count != 0)
                {
                    // See if only a Screen or Entity changed.  If so, do a simple set of that and be done with it


                    bool wasHandled = true;

                    List <string> elementsAlreadyRefreshed = new List <string>();

                    //if (comparisonObject.Differences.Count == 1)
                    foreach (string compDifference in comparisonObject.Differences)
                    {
                        ComparisonDifference comparison = comparisonObject.GetComparisonDifference(compDifference);
                        //comparisonObject.GetComparisonDifference(comparisonObject.Differences[0]);
                        int      indexInOld;
                        int      indexInNew;
                        IElement element     = GetElementFromObjectString(comparison.FullObject1, ProjectManager.GlueProjectSave, out indexInOld);
                        IElement replacement = GetElementFromObjectString(comparison.FullObject1, newGlueProjectSave, out indexInNew);

                        if (element != null && replacement != null && indexInNew == indexInOld)
                        {
                            if (!elementsAlreadyRefreshed.Contains(element.Name))
                            {
                                elementsAlreadyRefreshed.Add(element.Name);
                                if (element is ScreenSave)
                                {
                                    ProjectManager.GlueProjectSave.Screens[indexInOld] = newGlueProjectSave.Screens[indexInNew];
                                }
                                else // element is EntitySave
                                {
                                    ProjectManager.GlueProjectSave.Entities[indexInOld] = newGlueProjectSave.Entities[indexInNew];
                                }

                                var treeNode = GlueState.Self.Find.ElementTreeNode(element);


                                treeNode.SaveObject = replacement;


                                // Gotta regen this and update the UI and refresh the PropertyGrid if it's selected
                                GlueCommands.Self.UpdateCommands.Update(replacement);
                            }
                        }
                        else
                        {
                            wasHandled = false;
                            break;
                        }
                    }
                    if (!wasHandled)
                    {
                        ProjectLoader.Self.LoadProject(ProjectManager.ProjectBase.FullFileName);
                    }
                }
            }
            else
            {
                ProjectLoader.Self.LoadProject(ProjectManager.ProjectBase.FullFileName);
            }
            PluginManager.RefreshGlux();


            // Now that everything is done we want to re-select the same object (if we can)
            if (parentElement != null)
            {
                IElement newElement = ObjectFinder.Self.GetIElement(parentElement.Name);

                if (newElement != null)
                {
                    if (selectedObject != null && selectedObject is NamedObjectSave)
                    {
                        MainGlueWindow.Self.BeginInvoke(
                            new EventHandler(delegate
                        {
                            NamedObjectSave newNos = newElement.GetNamedObject(((NamedObjectSave)selectedObject).InstanceName);

                            // forces a refresh:
                            ElementViewWindow.SelectedNode = null;
                            ElementViewWindow.SelectedNode = GlueState.Self.Find.NamedObjectTreeNode(newNos);
                        }));
                    }
                }
            }
        }