private IUiElement TestElementsCollectionOfCertainType(ControlType controlType, out IUiElement[] elements)
 {
     // Arrange
     IUiElement[] elementsArray =
         new[] {
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty)
         };
     elements = elementsArray;
     IUiElement element =
         FakeFactory.GetElement_ForFindAll(
             elements,
             new PropertyCondition(
                 AutomationElement.ControlTypeProperty,
                 controlType));
     
     return element;
 }
 public void Buttons_Descendants_One()
 {
     // Arrange
     ControlType controlType = ControlType.Button;
     IUiElement[] elements =
         new[] { FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty) };
     IUiElement element =
         FakeFactory.GetElement_ForFindAll(
             elements,
             new PropertyCondition(
                 AutomationElement.ControlTypeProperty,
                 controlType));
     
     // Act
     var resultCollection = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Buttons;
     
     // Assert
     MbUnit.Framework.Assert.AreEqual(AutomationFactory.GetUiEltCollection(elements), resultCollection);
     Xunit.Assert.Equal(AutomationFactory.GetUiEltCollection(elements), resultCollection);
 }
        public void Search_Descendants_ClassName_1of3()
        {
            // Arrange
            const string expectedClassName = "cl01";
            IUiElement[] elementsArray =
                new[] {
                    FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, string.Empty),
                    FakeFactory.GetAutomationElementNotExpected(ControlType.Document, string.Empty, string.Empty, string.Empty, string.Empty),
                    FakeFactory.GetAutomationElementExpected(ControlType.Image, string.Empty, string.Empty, expectedClassName, string.Empty)
                };
            IUiElement element =
                FakeFactory.GetElement_ForFindAll(
                    elementsArray,
                    new PropertyCondition(
                        AutomationElement.ControlTypeProperty,
                        ControlType.Image));
            
            // Act
            var elementButton = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Buttons[expectedClassName][0];
            var elementDocument = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Documents[expectedClassName][0];
            var elementImage = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Images[expectedClassName][0];
            
            // Assert
            // 20140312
//            MbUnit.Framework.Assert.AreEqual(expectedClassName, (elementImage as IUiElement).Current.ClassName);
            MbUnit.Framework.Assert.AreEqual(expectedClassName, (elementImage as IUiElement).GetCurrent().ClassName);
//            MbUnit.Framework.Assert.IsNull(elementButton);
//            MbUnit.Framework.Assert.IsNull(elementDocument);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Calendars);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).CheckBoxes);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Customs);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).DataItems);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Edits);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Trees);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Windows);
            
            // 20140312
//            Xunit.Assert.Equal(expectedClassName, (elementImage as IUiElement).Current.ClassName);
            Xunit.Assert.Equal(expectedClassName, (elementImage as IUiElement).GetCurrent().ClassName);
        }
        public void VariousTypes_Descendants_Three()
        {
            // Arrange
            IUiElement[] elementsArray =
                new[] {
                    FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, string.Empty),
                    FakeFactory.GetAutomationElementExpected(ControlType.Document, string.Empty, string.Empty, string.Empty, string.Empty),
                    FakeFactory.GetAutomationElementExpected(ControlType.Image, string.Empty, string.Empty, string.Empty, string.Empty)
                };
            IUiElement element =
                FakeFactory.GetElement_ForFindAll(
                    elementsArray,
                    new PropertyCondition(
                        AutomationElement.ControlTypeProperty,
                        ControlType.Button));
            
            // Act
            var elementButton = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Buttons[0];
            var elementDocument = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Documents[1];
            var elementImage = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Images[2];
            
            // Assert
            // 20140312
//            MbUnit.Framework.Assert.AreEqual(ControlType.Button, elementButton.Current.ControlType); // (elementButton as IUiElement).Current.ControlType);
//            MbUnit.Framework.Assert.AreEqual(ControlType.Document, elementDocument.Current.ControlType); // (elementDocument as IUiElement).Current.ControlType);
//            MbUnit.Framework.Assert.AreEqual(ControlType.Image, elementImage.Current.ControlType); // (elementImage as IUiElement).Current.ControlType);
            MbUnit.Framework.Assert.AreEqual(ControlType.Button, elementButton.GetCurrent().ControlType);
            MbUnit.Framework.Assert.AreEqual(ControlType.Document, elementDocument.GetCurrent().ControlType);
            MbUnit.Framework.Assert.AreEqual(ControlType.Image, elementImage.GetCurrent().ControlType);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Calendars);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).CheckBoxes);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Customs);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).DataItems);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Edits);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Trees);
//            MbUnit.Framework.Assert.IsNull(((element as ISupportsExtendedModel).Descendants as IExtendedModel).Windows);
            
            // 20140312
//            Xunit.Assert.Equal(ControlType.Button, elementButton.Current.ControlType);
//            Xunit.Assert.Equal(ControlType.Document, elementDocument.Current.ControlType);
//            Xunit.Assert.Equal(ControlType.Image, elementImage.Current.ControlType);
            Xunit.Assert.Equal(ControlType.Button, elementButton.GetCurrent().ControlType);
            Xunit.Assert.Equal(ControlType.Document, elementDocument.GetCurrent().ControlType);
            Xunit.Assert.Equal(ControlType.Image, elementImage.GetCurrent().ControlType);
        }