Example #1
0
        protected override IPopUp FindProximateParentPopUp()
        {
            IPopUp parentPopUp = Substitute.For <IPopUp>();
            IPopUp nullPopUp   = null;

            parentPopUp.GetProximateParentPopUp().Returns(nullPopUp);
            return(parentPopUp);
        }
Example #2
0
    public void IsAncestorOf_Child_ReturnsTrue()
    {
        IPopUpConstArg arg        = CreateMockArg();
        TestPopUp      popUp      = new TestPopUp(arg);
        IPopUp         childPopUp = Substitute.For <IPopUp>();

        childPopUp.GetProximateParentPopUp().Returns(popUp);

        Assert.That(popUp.IsAncestorOf(childPopUp), Is.True);
    }
        void ReverseDisableOthers(IPopUp enablingPopUp)
        {
            IPopUp parentPopUp = enablingPopUp.GetProximateParentPopUp();

            if (parentPopUp != null)
            {
                parentPopUp.ReversePopUpDisableRecursively();
                RegisterPopUp(parentPopUp);
            }
            else
            {
                thisRootUIElement.ReversePopUpDisableRecursively();
                ClearActivePopUp();
            }
        }
    public void UnregiterPopUp_UnregedPopUpParentPopUpNull_SetsActiveNull()
    {
        IUIElement       rootUIElement = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager  = new TestPopUpManager();

        popUpManager.SetRootUIElement(rootUIElement);
        IPopUp popUpToUnreg            = Substitute.For <IPopUp>();
        IPopUp popUpToUnregParentPopUp = null;

        popUpToUnreg.GetProximateParentPopUp().Returns(popUpToUnregParentPopUp);
        popUpManager.SetActivePopUp_Test(popUpToUnreg);

        popUpManager.UnregisterPopUp(popUpToUnreg);

        Assert.That(popUpManager.GetActivePopUp_Test(), Is.Null);
    }
    public void UnregiterPopUp_UnregedPopUpParentPopUpNull_CallsRootUIEReverse()
    {
        IUIElement       rootUIElement = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager  = new TestPopUpManager();

        popUpManager.SetRootUIElement(rootUIElement);
        IPopUp popUpToUnreg            = Substitute.For <IPopUp>();
        IPopUp popUpToUnregParentPopUp = null;

        popUpToUnreg.GetProximateParentPopUp().Returns(popUpToUnregParentPopUp);
        popUpManager.SetActivePopUp_Test(popUpToUnreg);

        popUpManager.UnregisterPopUp(popUpToUnreg);

        rootUIElement.Received(1).ReversePopUpDisableRecursively();
    }
    public void RegisterPopUp_ActivePopUpIsNotChild_CallActivePopUp()
    {
        IUIElement       rootUIE      = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager = new TestPopUpManager();

        popUpManager.SetRootUIElement(rootUIE);
        IPopUp popUpToRegister = Substitute.For <IPopUp>();
        IPopUp activePopUp     = Substitute.For <IPopUp>();
        IPopUp nullPopUp       = null;

        activePopUp.GetProximateParentPopUp().Returns(nullPopUp);
        popUpManager.SetActivePopUp_Test(activePopUp);

        popUpManager.RegisterPopUp(popUpToRegister);

        activePopUp.Received(1).PopUpDisableRecursivelyDownTo(popUpToRegister);
    }
Example #7
0
        public bool IsAncestorOf(IPopUp other)
        {
            IPopUp popUpToExamine = other.GetProximateParentPopUp();

            while (true)
            {
                if (popUpToExamine == null)
                {
                    return(false);
                }
                if (popUpToExamine == this)
                {
                    return(true);
                }
                popUpToExamine = popUpToExamine.GetProximateParentPopUp();
            }
        }
    public void UnregiterPopUp_UnregedPopUpParentPopUpNotNull_CallsItInSequence()
    {
        IUIElement       rootUIElement = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager  = new TestPopUpManager();

        popUpManager.SetRootUIElement(rootUIElement);
        IPopUp popUpToUnreg            = Substitute.For <IPopUp>();
        IPopUp popUpToUnregParentPopUp = Substitute.For <IPopUp>();

        popUpToUnreg.GetProximateParentPopUp().Returns(popUpToUnregParentPopUp);
        popUpToUnregParentPopUp.IsAncestorOf(popUpToUnreg).Returns(true);
        popUpManager.SetActivePopUp_Test(popUpToUnreg);//this, or any other offspring will do

        popUpManager.UnregisterPopUp(popUpToUnreg);

        popUpToUnregParentPopUp.Received(1).ReversePopUpDisableRecursively();
        popUpToUnregParentPopUp.Received(1).ShowHiddenProximateParentPopUpRecursively();
        popUpToUnreg.DidNotReceive().PopUpDisableRecursivelyDownTo(popUpToUnregParentPopUp);
    }