public void DoesNotInteractIfGroupingDisabled()
        {
            var disabledGroup = new IssueGroup(nextProvider, "disabled group");

            disabledGroup.AddIssue(new IssueSummary());
            Assert.IsFalse(nextProvider.GetIssueGroupCalled, "The provider should not be called by a disabled group.");
        }
        public void PassesIssueSummaryToExistingGroupDuringEnableProcessing()
        {
            var disabledGroup = new IssueGroup(nextProvider, "sut");

            // "prime" the tree of groups
            nextProvider.Group = CreateSecondaryGroup();
            disabledGroup.AddIssue(new IssueSummary());

            var probe = new IssueSummary();

            disabledGroup.AddIssue(probe);
            disabledGroup.EnableProcessing();
            var issues = ((IIssueTreeNode)nextProvider.Group).Children;

            Assert.IsTrue(issues.Contains(probe), "The issue was not added to the existing group.");
        }
        public void DoesNotCallChildAddedEventHandlersIfNotEnabled()
        {
            var            disabledGroup = new IssueGroup(null, "disabledNode");
            IIssueTreeNode disabledNode  = disabledGroup;

            nextProvider.Group = CreateSecondaryGroup();

            disabledNode.ChildAdded += Forbidden <IssueTreeNodeEventArgs> ("node.ChildAdded");
            disabledGroup.AddIssue(new IssueSummary());
        }
        public void CallsTextChangedEventHandlersWhenIssueIsAddedToNonProcessingGroup()
        {
            var  inactiveGroup            = new IssueGroup(nextProvider, "sut");
            bool textChangedHandlerCalled = false;

            ((IIssueTreeNode)inactiveGroup).TextChanged += delegate {
                textChangedHandlerCalled = true;
            };

            inactiveGroup.AddIssue(new IssueSummary());
            Assert.IsTrue(textChangedHandlerCalled, "The event handler was not called.");
        }
        public void LeavesFilteredCorrectly()
        {
            var            leafGroup = new IssueGroup(NullGroupingProvider.Instance, "sut");
            IIssueTreeNode leafNode  = leafGroup;
            var            issue     = new IssueSummary();

            leafGroup.AddIssue(issue);

            var children = leafNode.Children;

            Assert.That(children.Contains(issue));
            Assert.AreEqual(1, children.Count, "The group contained too many issues.");
        }
        public void NoEventsCalledForIssuesAddedBeforeProcessingEnabled()
        {
            var            localGroup = new IssueGroup(null, "sut");
            IIssueTreeNode localNode  = localGroup;

            localNode.ChildAdded += Forbidden <IssueTreeNodeEventArgs> ("node.ChildAdded");
            var issue = new IssueSummary();

            localGroup.AddIssue(issue);

            var children = localNode.Children;

            Assert.That(children.Contains(issue));
            Assert.AreEqual(1, children.Count, "The number of children was incorrect.");
        }
        public void CallsChildAddedEventHandlers()
        {
            nextProvider.Group = CreateSecondaryGroup();

            bool eventHandlerCalled      = false;
            bool groupEventHandlerCalled = false;

            ((IIssueTreeNode)nextProvider.Group).ChildAdded += delegate {
                groupEventHandlerCalled = true;
            };
            node.ChildAdded += delegate {
                eventHandlerCalled = true;
            };

            group.AddIssue(new IssueSummary());
            Assert.IsTrue(eventHandlerCalled, "The event handler for the root group was not called.");
            Assert.IsTrue(groupEventHandlerCalled, "The event handler for the nested group was not called.");
        }