public bool IsElementOfKind(UnitTestElement element, UnitTestElementKind kind)
            {
                if (element == null)
                {
                    throw new ArgumentNullException("element");
                }

                GallioTestElement gallioTestElement = element as GallioTestElement;

                if (gallioTestElement == null)
                {
                    return(false);
                }

                switch (kind)
                {
                case UnitTestElementKind.Unknown:
                case UnitTestElementKind.TestStuff:
                    return(false);

                case UnitTestElementKind.Test:
                    return(gallioTestElement.IsTestCase);

                case UnitTestElementKind.TestContainer:
                    return(!gallioTestElement.IsTestCase);

                default:
                    throw new ArgumentOutOfRangeException("kind");
                }
            }
            private void AddTestTasksFromRootToLeaf(List <UnitTestTask> tasks, GallioTestElement element)
            {
                GallioTestElement parentElement = element.Parent as GallioTestElement;

                if (parentElement != null)
                {
                    AddTestTasksFromRootToLeaf(tasks, parentElement);
                }

                tasks.Add(new UnitTestTask(element, FacadeTaskFactory.CreateTestTaskFrom(element)));
            }
            /// <summary>
            /// Compares unit tests elements to determine relative sort order.
            /// </summary>
            public int CompareUnitTestElements(UnitTestElement x, UnitTestElement y)
            {
                if (x == null)
                {
                    throw new ArgumentNullException("x");
                }
                if (y == null)
                {
                    throw new ArgumentNullException("y");
                }

                GallioTestElement xe = (GallioTestElement)x;
                GallioTestElement ye = (GallioTestElement)y;

                return(xe.CompareTo(ye));
            }
        private void PresentTestElement(GallioTestElement value, IPresentableItem item,
                                        TreeModelNode modelNode, PresentationState state)
        {
            item.Clear();

            item.RichText = value.TestName;

#if RESHARPER_60_OR_NEWER
            if (value.Explicit)
            {
                item.RichText.SetForeColor(SystemColors.GrayText);
            }

            var typeImage  = UnitTestIconManager.GetStandardImage(UnitTestElementImage.Test);
            var stateImage = UnitTestIconManager.GetStateImage(state);
            if (stateImage != null)
            {
                item.Images.Add(stateImage);
            }
            else if (typeImage != null)
            {
                item.Images.Add(typeImage);
            }
#else
            if (value.IsExplicit)
            {
                item.RichText.SetForeColor(SystemColors.GrayText);
            }

            Image image = UnitTestManager.GetStateImage(state);

            if (image == null)
            {
                image = UnitTestManager.GetStandardImage(value.IsTestCase ? UnitTestElementImage.Test : UnitTestElementImage.TestCategory);
            }

            if (image != null)
            {
                item.Images.Add(image);
            }

            if (!value.IsTestCase)
            {
                AppendOccurencesCount(item, modelNode, "test");
            }
#endif
        }
                private void HandleTestDiscoveredMessage(TestDiscoveredMessage message)
                {
                    GallioTestElement element;

                    if (!tests.TryGetValue(message.Test.Id, out element))
                    {
                        if (ShouldTestBePresented(message.Test.CodeElement))
                        {
                            GallioTestElement parentElement;
                            tests.TryGetValue(message.ParentTestId, out parentElement);

                            element = GallioTestElement.CreateFromTest(message.Test, message.Test.CodeElement, provider, parentElement);
                            consumer(element);
                        }

                        tests.Add(message.Test.Id, element);
                    }
                }
            /// <summary>
            /// Gets task information for <see cref="T:JetBrains.ReSharper.TaskRunnerFramework.RemoteTaskRunner" /> from element.
            /// </summary>
            public IList <UnitTestTask> GetTaskSequence(UnitTestElement element, IList <UnitTestElement> explicitElements)
            {
                if (element == null)
                {
                    throw new ArgumentNullException("element");
                }
                if (explicitElements == null)
                {
                    throw new ArgumentNullException("explicitElements");
                }

                GallioTestElement   topElement = (GallioTestElement)element;
                List <UnitTestTask> tasks      = new List <UnitTestTask>();

                // Add the run task.  Must always be first.
                tasks.Add(new UnitTestTask(null, FacadeTaskFactory.CreateRootTask()));

                // Add the test case branch.
                AddTestTasksFromRootToLeaf(tasks, topElement);

                // Now that we're done with the critical parts of the task tree, we can add other
                // arbitrary elements.  We don't care about the structure of the task tree beyond this depth.

                // Add the assembly location.
                tasks.Add(new UnitTestTask(null, FacadeTaskFactory.CreateAssemblyTaskFrom(topElement)));

                if (explicitElements.Count != 0)
                {
                    // Add explicit element markers.
                    foreach (GallioTestElement explicitElement in explicitElements)
                    {
                        tasks.Add(new UnitTestTask(null, FacadeTaskFactory.CreateExplicitTestTaskFrom(explicitElement)));
                    }
                }
                else
                {
                    // No explicit elements but we must have at least one to filter by, so we consider
                    // the top test explicitly selected.
                    tasks.Add(new UnitTestTask(null, FacadeTaskFactory.CreateExplicitTestTaskFrom(topElement)));
                }

                return(tasks);
            }
Exemple #7
0
        private static void PresentTestElement(GallioTestElement value, IPresentableItem item, TreeModelNode modelNode, PresentationState state)
        {
            item.Clear();

            item.RichText = value.TestName;

            if (value.Explicit)
            {
                item.RichText.SetForeColor(SystemColors.GrayText);
            }

            var typeImage  = UnitTestIconManager.GetStandardImage(UnitTestElementImage.Test);
            var stateImage = UnitTestIconManager.GetStateImage(state);

            if (stateImage != null)
            {
                item.Images.Add(stateImage);
            }
            else if (typeImage != null)
            {
                item.Images.Add(typeImage);
            }
        }
 public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
 {
     return(GallioTestElement.Deserialize(parent, parentElement, this));
 }