Example #1
0
    public void HideShownChildPopUpsRecursively_ChildIsActivated_ChildIsShown_CallsItInSequence()
    {
        IPopUpConstArg arg   = CreateMockArg();
        TestPopUp      popUp = new TestPopUp(arg);

        popUp.SetUpPopUpHierarchy();

        List <IPopUp> calledChildrent = new List <IPopUp>();

        for (int i = 0; i < 3; i++)
        {
            IPopUp childPopUp = Substitute.For <IPopUp>();
            childPopUp.IsActivated().Returns(true);
            childPopUp.IsShown().Returns(true);
            popUp.RegisterProximateChildPopUp(childPopUp);
            calledChildrent.Add(childPopUp);
        }
        List <IPopUp> notCalledChildren = new List <IPopUp>();

        for (int i = 0; i < 3; i++)
        {
            IPopUp childPopUp = Substitute.For <IPopUp>();
            childPopUp.IsActivated().Returns(false);
            childPopUp.IsShown().Returns(true);
            popUp.RegisterProximateChildPopUp(childPopUp);
            notCalledChildren.Add(childPopUp);
        }
        List <IPopUp> notCalledChildren2 = new List <IPopUp>();

        for (int i = 0; i < 3; i++)
        {
            IPopUp childPopUp = Substitute.For <IPopUp>();
            childPopUp.IsActivated().Returns(true);
            childPopUp.IsShown().Returns(false);
            popUp.RegisterProximateChildPopUp(childPopUp);
            notCalledChildren2.Add(childPopUp);
        }

        popUp.HideShownChildPopUpsRecursively();

        foreach (IPopUp childPopUp in calledChildrent)
        {
            childPopUp.Received(1).Hide(false);
            childPopUp.Received(1).HideShownChildPopUpsRecursively();
        }
        foreach (IPopUp childPopUp in notCalledChildren)
        {
            childPopUp.DidNotReceive().Hide(false);
            childPopUp.DidNotReceive().HideShownChildPopUpsRecursively();
        }
        foreach (IPopUp childPopUp in notCalledChildren2)
        {
            childPopUp.DidNotReceive().Hide(false);
            childPopUp.DidNotReceive().HideShownChildPopUpsRecursively();
        }
    }
Example #2
0
    public void ShowHiddenProximateParentPopUpRecursively_ProxParNotNull_ProxParIsHidden_CallsItInSequence()
    {
        IPopUpConstArg arg   = CreateMockArg();
        TestPopUp      popUp = new TestPopUp(arg);

        popUp.SetUpPopUpHierarchy();
        IPopUp parentPopUp = popUp.GetProximateParentPopUp();

        parentPopUp.IsHidden().Returns(true);

        popUp.ShowHiddenProximateParentPopUpRecursively();

        parentPopUp.Received(1).Show(false);
        parentPopUp.Received(1).ShowHiddenProximateParentPopUpRecursively();
    }
    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);
    }
    public void UnregiterPopUp_CallsPopUpToUnregHideShow()
    {
        IUIElement       rootUIElement = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager  = new TestPopUpManager();

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

        popUpManager.UnregisterPopUp(popUpToUnreg);

        popUpToUnreg.Received(1).HideShownChildPopUpsRecursively();
    }
    public void RegisterPopUp_CallsPopUpToRegisterShowHidden()
    {
        IPopUp           popUpToRegister = Substitute.For <IPopUp>();
        IUIElement       rootUIElement   = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager    = new TestPopUpManager();

        popUpManager.SetRootUIElement(rootUIElement);

        popUpManager.RegisterPopUp(popUpToRegister);

        popUpToRegister.Received(1).ShowHiddenProximateParentPopUpRecursively();
    }
    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);
    }