public T Calculate()
        {
            IUIElement uieToExamine = thisUIElementToExamine;

            while (true)
            {
                IUIElement parentUIE = uieToExamine.GetParentUIE();
                if (parentUIE != null)
                {
                    if (parentUIE is T)
                    {
                        return((T)parentUIE);
                    }
                    else
                    {
                        uieToExamine = parentUIE;
                    }
                }
                else
                {
                    break;
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
    public void Calculate_NoParentUIE_ReturnsNull()
    {
        IUIElement uie    = Substitute.For <IUIElement>();
        IUIElement parent = null;

        uie.GetParentUIE().Returns(parent);

        IProximateParentTypedUIECalculator <ISomeTestUIElement> calculator = new ProximateParentTypedUIECalculator <ISomeTestUIElement>(uie);

        Assert.That(calculator.Calculate(), Is.Null);
    }
Ejemplo n.º 3
0
    public void Calculate_HasScrollerParentDirectlyAbove_ReturnsIt()
    {
        IUIElement         uie         = Substitute.For <IUIElement>();
        ISomeTestUIElement typedParent = Substitute.For <ISomeTestUIElement>();
        IUIElement         nullParent  = null;

        uie.GetParentUIE().Returns(typedParent);
        typedParent.GetParentUIE().Returns(nullParent);

        IProximateParentTypedUIECalculator <ISomeTestUIElement> calculator = new ProximateParentTypedUIECalculator <ISomeTestUIElement>(uie);

        Assert.That(calculator.Calculate(), Is.SameAs(typedParent));
    }
Ejemplo n.º 4
0
    public void Calculate_HasMultipleScrollerParentAbove_ReturnsTheColosest()
    {
        IUIElement         uie = Substitute.For <IUIElement>();
        ISomeTestUIElement closeTypedParent = Substitute.For <ISomeTestUIElement>();
        ISomeTestUIElement farTypedParent   = Substitute.For <ISomeTestUIElement>();
        IUIElement         nullParent       = null;

        uie.GetParentUIE().Returns(closeTypedParent);
        closeTypedParent.GetParentUIE().Returns(farTypedParent);
        farTypedParent.GetParentUIE().Returns(nullParent);

        IProximateParentTypedUIECalculator <ISomeTestUIElement> calculator = new ProximateParentTypedUIECalculator <ISomeTestUIElement>(uie);

        Assert.That(calculator.Calculate(), Is.SameAs(closeTypedParent));
    }