[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] // [Description("Checks that the basic elements' object model works, while the extended elements' object model is also on")] public void Toggle_Toggle_Off_ExtendedObjectModel_On() { // Arrange Preferences.UseElementsSearchObjectModel = true; var expectedValue = ToggleState.Off; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTogglePattern(new PatternsData()) }) as ISupportsTogglePattern; // Act element.ToggleState.Returns(ToggleState.On); element.Toggle(); try { (element as IUiElement).GetCurrentPattern <ITogglePattern>(TogglePattern.Pattern).Received().Toggle(); if (ToggleState.On == element.ToggleState) { element.ToggleState.Returns(ToggleState.Off); } } catch {} // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.ToggleState); Assert.Equal(expectedValue, element.ToggleState); }
public void Dock_DockPosition() { // Arrange DockPosition expectedValue = DockPosition.Bottom; ISupportsDockPattern element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData() { DockPattern_DockPosition = expectedValue }) }) as ISupportsDockPattern; // // Arrange // ExpandCollapseState expectedValue = ExpandCollapseState.Expanded; // ISupportsExpandCollapsePattern element = // FakeFactory.GetAutomationElementForMethodsOfObjectModel( // new IBasePattern[] { FakeFactory.GetExpandCollapsePattern(new PatternsData() { ExpandCollapsePattern_ExpandCollapseState = expectedValue }) }) as ISupportsExpandCollapsePattern; // // Act // element.SetDockPosition(expectedValue); // // // Assert // Assert.AreEqual(expectedValue, element.DockPosition); // Act // Assert CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$input | %{ $_.DockPosition; }", new [] { element }, expectedValue.ToString()); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Dock_ImplementsCommonPattern() { // ISupportsInvokePattern invokableElement = // FakeFactory.GetAutomationElementForMethodsOfObjectModel( // new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsInvokePattern; // // MbUnit.Framework.Assert.IsNotNull(invokableElement as ISupportsInvokePattern); var highlightableElement = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsHighlighter; MbUnit.Framework.Assert.IsNotNull(highlightableElement as ISupportsHighlighter); Xunit.Assert.NotNull(highlightableElement as ISupportsHighlighter); var navigatableElement = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsNavigation; MbUnit.Framework.Assert.IsNotNull(navigatableElement as ISupportsNavigation); var conversibleElement = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsConversion; MbUnit.Framework.Assert.IsNotNull(conversibleElement as ISupportsConversion); var refreshableElement = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsRefresh; MbUnit.Framework.Assert.IsNotNull(refreshableElement as ISupportsRefresh); }
public void TableItem_TableContainingGrid() { // Arrange var expectedValue = new UiElement(); var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTableItemPattern(new PatternsData() { TableItemPattern_ContainingGrid = expectedValue }) }) as ISupportsTableItemPattern; // Act // Assert // Assert.AreEqual(expectedValue as IUiElement, element.TableContainingGrid as IUiElement); // 20140312 // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.Name, element.TableContainingGrid.Current.Name); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.AutomationId, element.TableContainingGrid.Current.AutomationId); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.ClassName, element.TableContainingGrid.Current.ClassName); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.ControlType, element.TableContainingGrid.Current.ControlType); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.BoundingRectangle, element.TableContainingGrid.Current.BoundingRectangle); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.NativeWindowHandle, element.TableContainingGrid.Current.NativeWindowHandle); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.ProcessId, element.TableContainingGrid.Current.ProcessId); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.IsEnabled, element.TableContainingGrid.Current.IsEnabled); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.IsOffscreen, element.TableContainingGrid.Current.IsOffscreen); // MbUnit.Framework.Assert.AreEqual(expectedValue.Current.AcceleratorKey, element.TableContainingGrid.Current.AcceleratorKey); // // Xunit.Assert.Equal(expectedValue.Current.Name, element.TableContainingGrid.Current.Name); // Xunit.Assert.Equal(expectedValue.Current.AutomationId, element.TableContainingGrid.Current.AutomationId); // Xunit.Assert.Equal(expectedValue.Current.ClassName, element.TableContainingGrid.Current.ClassName); // Xunit.Assert.Equal(expectedValue.Current.ControlType, element.TableContainingGrid.Current.ControlType); // Xunit.Assert.Equal(expectedValue.Current.BoundingRectangle, element.TableContainingGrid.Current.BoundingRectangle); // Xunit.Assert.Equal(expectedValue.Current.NativeWindowHandle, element.TableContainingGrid.Current.NativeWindowHandle); // Xunit.Assert.Equal(expectedValue.Current.ProcessId, element.TableContainingGrid.Current.ProcessId); // Xunit.Assert.Equal(expectedValue.Current.IsEnabled, element.TableContainingGrid.Current.IsEnabled); // Xunit.Assert.Equal(expectedValue.Current.IsOffscreen, element.TableContainingGrid.Current.IsOffscreen); // Xunit.Assert.Equal(expectedValue.Current.AcceleratorKey, element.TableContainingGrid.Current.AcceleratorKey); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().Name, element.TableContainingGrid.GetCurrent().Name); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().AutomationId, element.TableContainingGrid.GetCurrent().AutomationId); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().ClassName, element.TableContainingGrid.GetCurrent().ClassName); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().ControlType, element.TableContainingGrid.GetCurrent().ControlType); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().BoundingRectangle, element.TableContainingGrid.GetCurrent().BoundingRectangle); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().NativeWindowHandle, element.TableContainingGrid.GetCurrent().NativeWindowHandle); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().ProcessId, element.TableContainingGrid.GetCurrent().ProcessId); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().IsEnabled, element.TableContainingGrid.GetCurrent().IsEnabled); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().IsOffscreen, element.TableContainingGrid.GetCurrent().IsOffscreen); MbUnit.Framework.Assert.AreEqual(expectedValue.GetCurrent().AcceleratorKey, element.TableContainingGrid.GetCurrent().AcceleratorKey); Assert.Equal(expectedValue.GetCurrent().Name, element.TableContainingGrid.GetCurrent().Name); Assert.Equal(expectedValue.GetCurrent().AutomationId, element.TableContainingGrid.GetCurrent().AutomationId); Assert.Equal(expectedValue.GetCurrent().ClassName, element.TableContainingGrid.GetCurrent().ClassName); Assert.Equal(expectedValue.GetCurrent().ControlType, element.TableContainingGrid.GetCurrent().ControlType); Assert.Equal(expectedValue.GetCurrent().BoundingRectangle, element.TableContainingGrid.GetCurrent().BoundingRectangle); Assert.Equal(expectedValue.GetCurrent().NativeWindowHandle, element.TableContainingGrid.GetCurrent().NativeWindowHandle); Assert.Equal(expectedValue.GetCurrent().ProcessId, element.TableContainingGrid.GetCurrent().ProcessId); Assert.Equal(expectedValue.GetCurrent().IsEnabled, element.TableContainingGrid.GetCurrent().IsEnabled); Assert.Equal(expectedValue.GetCurrent().IsOffscreen, element.TableContainingGrid.GetCurrent().IsOffscreen); Assert.Equal(expectedValue.GetCurrent().AcceleratorKey, element.TableContainingGrid.GetCurrent().AcceleratorKey); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Current_On() { Preferences.UseElementsCurrent = true; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsCurrent; var testCurrent = element.Current; }
public void Selection_ImplementsPatternInQuestion() { var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetSelectionPattern(new PatternsData()) }) as ISupportsSelectionPattern; MbUnit.Framework.Assert.IsNotNull(element as ISupportsSelectionPattern); Assert.NotNull(element as ISupportsSelectionPattern); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Table_ImplementsExportPattern() { var exportableElement = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetGridPattern(new PatternsData()) }) as ISupportsExport; MbUnit.Framework.Assert.IsNotNull(exportableElement as ISupportsExport); Assert.NotNull(exportableElement as ISupportsExport); }
public void TableItem_DoesNotImplementOtherPatterns() { var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTableItemPattern(new PatternsData()) }) as ISupportsValuePattern; MbUnit.Framework.Assert.IsNull(element as ISupportsValuePattern); Assert.Null(element as ISupportsValuePattern); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Current_Off() { Preferences.UseElementsCurrent = false; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsCurrent; MbUnit.Framework.Assert.IsNull(element); Xunit.Assert.Null(element); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Invoke_Invoke() { // Arrange var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetInvokePattern(new PatternsData()) }) as ISupportsInvokePattern; // Act // Assert element.Invoke(); }
public void Grid_ExportToCsv() { // Arrange var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetGridPattern(new PatternsData()) }) as ISupportsExport; // Act // Assert element.ExportToCsv(); }
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 }
public void Window_IsTopmost() { // Arrange const bool expectedValue = false; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetWindowPattern(new PatternsData() { WindowPattern_IsTopmost = expectedValue }) }) as ISupportsWindowPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.IsTopmost); Assert.Equal(expectedValue, element.IsTopmost); }
public void Window_WindowVisualState() { // Arrange var expectedValue = WindowVisualState.Normal; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetWindowPattern(new PatternsData() { WindowPattern_WindowVisualState = expectedValue }) }) as ISupportsWindowPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.WindowVisualState); Assert.Equal(expectedValue, element.WindowVisualState); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Text_SupportedTextSelection() { // Arrange var expectedValue = SupportedTextSelection.Single; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTextPattern(new PatternsData() { TextPattern_SupportedTextSelection = expectedValue }) }) as ISupportsTextPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.SupportedTextSelection); }
public void Text_DocumentRange() { // Arrange var expectedValue = new object() as TextPatternRange; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTextPattern(new PatternsData() { TextPattern_DocumentRange = expectedValue }) }) as ISupportsTextPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.DocumentRange); }
public void Value_Value_Get() { // Arrange const string expectedValue = "abc"; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetValuePattern(new PatternsData() { ValuePattern_Value = expectedValue }) }) as ISupportsValuePattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.Value); Assert.Equal(expectedValue, element.Value); }
public void Scroll_HorizontalScrollPercent() { // Arrange const double expectedValue = 12.1; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetScrollPattern(new PatternsData() { ScrollPattern_HorizontalScrollPercent = expectedValue }) }) as ISupportsScrollPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.HorizontalScrollPercent); Assert.Equal(expectedValue, element.HorizontalScrollPercent); }
public void Scroll_VerticalViewSize() { // Arrange const double expectedValue = 18.4; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetScrollPattern(new PatternsData() { ScrollPattern_VerticalViewSize = expectedValue }) }) as ISupportsScrollPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.VerticalViewSize); Assert.Equal(expectedValue, element.VerticalViewSize); }
public void Selection_IsSelectionRequired() { // Arrange const bool expectedValue = false; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetSelectionPattern(new PatternsData() { SelectionPattern_IsSelectionRequired = expectedValue }) }) as ISupportsSelectionPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.IsSelectionRequired); Assert.Equal(expectedValue, element.IsSelectionRequired); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void GridItem_GridColumn() { // Arrange const int expectedValue = 3; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetGridItemPattern(new PatternsData() { GridItemPattern_Column = expectedValue }) }) as ISupportsGridItemPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.GridColumn); Xunit.Assert.Equal(expectedValue, element.GridColumn); }
public void SelectionItem_SelectionContainer() { // Arrange var expectedValue = new UiElement(); var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetSelectionItemPattern(new PatternsData() { SelectionItemPattern_SelectionContainer = expectedValue }) }) as ISupportsSelectionItemPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.SelectionContainer); Assert.Equal(expectedValue, element.SelectionContainer); }
public void RangeValue_SmallChange() { // Arrange const double expectedValue = 5.4; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetRangeValuePattern(new PatternsData() { RangeValuePattern_SmallChange = expectedValue }) }) as ISupportsRangeValuePattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.SmallChange); Assert.Equal(expectedValue, element.SmallChange); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Toggle_ToggleState_On() { // Arrange var expectedValue = ToggleState.On; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTogglePattern(new PatternsData() { TogglePattern_ToggleState = expectedValue }) }) as ISupportsTogglePattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.ToggleState); Assert.Equal(expectedValue, element.ToggleState); }
public void Transform_CanRotate() { // Arrange const bool expectedValue = true; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTransformPattern(new PatternsData() { TransformPattern_CanRotate = expectedValue }) }) as ISupportsTransformPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.CanRotate); Assert.Equal(expectedValue, element.CanRotate); }
[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 TableItem_TableRowSpan() { // Arrange const int expectedValue = 6; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTableItemPattern(new PatternsData() { TableItemPattern_RowSpan = expectedValue }) }) as ISupportsTableItemPattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.TableRowSpan); Assert.Equal(expectedValue, element.TableRowSpan); }
public void RangeValue_IsRangeReadOnly() { // Arrange const bool expectedValue = true; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetRangeValuePattern(new PatternsData() { RangeValuePattern_IsReadOnly = expectedValue }) }) as ISupportsRangeValuePattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.IsRangeReadOnly); Assert.Equal(expectedValue, element.IsRangeReadOnly); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Highlighter() { // Arrange // DockPosition expectedValue = DockPosition.Bottom; // 20140312 // ISupportsHighlighter element = var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetDockPattern(new PatternsData()) }) as ISupportsHighlighter; // Act // element.SetDockPosition(expectedValue); element.Highlight(); // Assert // Assert.AreEqual(expectedValue, element.DockPosition); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Table_RowOrColumnMajor() { // Arrange RowOrColumnMajor expectedValue = RowOrColumnMajor.ColumnMajor; var element = FakeFactory.GetAutomationElementForMethodsOfObjectModel( new IBasePattern[] { FakeFactory.GetTablePattern(new PatternsData() { TablePattern_RowOrColumnMajor = expectedValue }) }) as ISupportsTablePattern; // Act // Assert MbUnit.Framework.Assert.AreEqual(expectedValue, element.RowOrColumnMajor); Assert.Equal(expectedValue, element.RowOrColumnMajor); }