Ejemplo n.º 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();
        }
    }
Ejemplo n.º 2
0
    public void RegisterPopUp_PopUpToRegIsAncestorOfActive_DoesNotCallActivePopUp()
    {
        IUIElement       rootUIE      = Substitute.For <IUIElement>();
        TestPopUpManager popUpManager = new TestPopUpManager();

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

        popUpToRegister.IsAncestorOf(activePopUp).Returns(true);
        popUpManager.SetActivePopUp_Test(activePopUp);

        popUpManager.RegisterPopUp(popUpToRegister);

        rootUIE.DidNotReceive().PopUpDisableRecursivelyDownTo(popUpToRegister);
        activePopUp.DidNotReceive().PopUpDisableRecursivelyDownTo(popUpToRegister);
    }
Ejemplo n.º 3
0
    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);
    }