public void IsAncestorOf_Parent_ReturnsFalse() { IPopUpConstArg arg = CreateMockArg(); TestPopUp popUp = new TestPopUp(arg); IPopUp childPopUp = Substitute.For <IPopUp>(); childPopUp.GetProximateParentPopUp().Returns(popUp); Assert.That(childPopUp.IsAncestorOf(popUp), Is.False); }
void DisableOthers(IPopUp disablingPopUp) { if (thisActivePopUp == null) { thisRootUIElement.PopUpDisableRecursivelyDownTo(disablingPopUp); } else { if (disablingPopUp.IsAncestorOf(thisActivePopUp)) { return; } thisActivePopUp.PopUpDisableRecursivelyDownTo(disablingPopUp); } }
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); }
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); }