[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void ExpandCollapse_DoesNotImplementOtherPatterns()
        {
            var element =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsValuePattern;

            MbUnit.Framework.Assert.IsNull(element as ISupportsValuePattern);
            Xunit.Assert.Null(element as ISupportsValuePattern);
        }
        public void ExpandCollapseState_Expanded()
        {
            // Arrange
            const ExpandCollapseState expectedValue = ExpandCollapseState.Expanded;
            var element =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()
                {
                    ExpandCollapsePattern_ExpandCollapseState = expectedValue
                }) }) as ISupportsExpandCollapsePattern;

            #region commented
//if (null == element) {
//    Console.WriteLine("null == element");
//} else {
//    Console.WriteLine("null != element");
//    try {
//        Console.WriteLine(element.ExpandCollapseState.ToString());
//    } catch (Exception e) {
//        Console.WriteLine(e.Message);
//        // throw;
//    }
//}
//var pattern = FakeFactory.GetExpandCollapsePattern(new PatternsData() { ExpandCollapsePattern_ExpandCollapseState = expectedValue });
//if (null == pattern) {
//    Console.WriteLine("null == pattern");
//} else {
//    Console.WriteLine("null != pattern");
//    try {
//        Console.WriteLine(pattern.Current.ExpandCollapseState.ToString());
//    } catch (Exception e2) {
//        Console.WriteLine(e2.Message);
//        // throw;
//    }
//}
            #endregion commented

            // Act
            // Assert
            var    data   = new object[] { @"$input | %{ $_.ExpandCollapseState; }", new [] { element }, expectedValue.ToString() };
            Thread thread = new Thread(RunTest);
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start(data);

            #region commented
//            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
//                // @"$input | %{ $_.ExpandCollapseState; }",
//                @"[System.EventHandler]$handler = { $input | %{ $_.ExpandCollapseState; } }; $handler.Invoke();",
//                null, //new [] { element },
//                expectedValue.ToString());
            #endregion commented
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void ExpandCollapse_PartiallyExpanded()
        {
            // Arrange
            const ExpandCollapseState expectedValue = ExpandCollapseState.PartiallyExpanded;
            var element =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()
                {
                    ExpandCollapsePattern_ExpandCollapseState = expectedValue
                }) }) as ISupportsExpandCollapsePattern;

            // Act

            // Assert
            MbUnit.Framework.Assert.AreEqual(expectedValue, element.ExpandCollapseState);
            Xunit.Assert.Equal(expectedValue, element.ExpandCollapseState);
        }
        public void ExpandCollapseState_PartiallyExpanded()
        {
            // Arrange
            ExpandCollapseState            expectedValue = ExpandCollapseState.PartiallyExpanded;
            ISupportsExpandCollapsePattern element       =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()
                {
                    ExpandCollapsePattern_ExpandCollapseState = expectedValue
                }) }) as ISupportsExpandCollapsePattern;

            #region commented
//if (null == element) {
//    Console.WriteLine("null == element");
//} else {
//    Console.WriteLine("null != element");
//    try {
//        Console.WriteLine(element.ExpandCollapseState.ToString());
//    } catch (Exception e) {
//        Console.WriteLine(e.Message);
//        // throw;
//    }
//}
//var pattern = FakeFactory.GetExpandCollapsePattern(new PatternsData() { ExpandCollapsePattern_ExpandCollapseState = expectedValue });
//if (null == pattern) {
//    Console.WriteLine("null == pattern");
//} else {
//    Console.WriteLine("null != pattern");
//    try {
//        Console.WriteLine(pattern.Current.ExpandCollapseState.ToString());
//    } catch (Exception e2) {
//        Console.WriteLine(e2.Message);
//        // throw;
//    }
//}
            #endregion commented

            // Act
            // Assert
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$input | %{ $_.ExpandCollapseState; }",
                // @"$input | %{ $_.GetSourceElement().ExpandCollapseState; }",
                new [] { element },
                // new [] { (element as IUiElement).GetSourceElement() },
                expectedValue.ToString());
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void ExpandCollapse_Expand()
        {
            // Arrange
            const ExpandCollapseState expectedValue = ExpandCollapseState.Expanded;
            var element =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsExpandCollapsePattern;

            // Act
            element.Expand();
            try {
                (element as IUiElement).GetCurrentPattern <IExpandCollapsePattern>(ExpandCollapsePattern.Pattern).Received().Expand();
                element.ExpandCollapseState.Returns(expectedValue);
            }
            catch {}

            // Assert
            MbUnit.Framework.Assert.AreEqual(expectedValue, element.ExpandCollapseState);
            Xunit.Assert.Equal(expectedValue, element.ExpandCollapseState);
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void ExpandCollapse_ImplementsCommonPattern()
        {
//            ISupportsInvokePattern invokableElement =
//                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
//                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsInvokePattern;
//
//            MbUnit.Framework.Assert.IsNotNull(invokableElement as ISupportsInvokePattern);

            var highlightableElement =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsHighlighter;

            MbUnit.Framework.Assert.IsNotNull(highlightableElement as ISupportsHighlighter);
            Xunit.Assert.NotNull(highlightableElement as ISupportsHighlighter);

            var navigatableElement =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsNavigation;

            MbUnit.Framework.Assert.IsNotNull(navigatableElement as ISupportsNavigation);
            Xunit.Assert.NotNull(navigatableElement as ISupportsNavigation);

            var conversibleElement =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsConversion;

            MbUnit.Framework.Assert.IsNotNull(conversibleElement as ISupportsConversion);
            Xunit.Assert.NotNull(conversibleElement as ISupportsConversion);

            var refreshableElement =
                FakeFactory.GetAutomationElementForMethodsOfObjectModel(
                    new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData()) }) as ISupportsRefresh;

            MbUnit.Framework.Assert.IsNotNull(refreshableElement as ISupportsRefresh);
            Xunit.Assert.NotNull(refreshableElement as ISupportsRefresh);
        }