public void Get3of3_NoRecurison_DifferentPids() { // Arrange const int pid01 = 111; const int pid02 = 222; const int pid03 = 333; TestParametersAgainstCollection( new[] { pid01, pid02, pid03 }, null, string.Empty, string.Empty, new IUiElement[] { FakeFactory.GetAutomationElementExpected( new ElementData { Current_ProcessId = pid01, Current_ControlType = ControlType.Window }), FakeFactory.GetAutomationElementExpected( new ElementData { Current_ProcessId = pid02, Current_ControlType = ControlType.Window }), FakeFactory.GetAutomationElementExpected( new ElementData { Current_ProcessId = pid03, Current_ControlType = ControlType.Window }) }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get0of4_byControlTypeClass_X2() { string name = string.Empty; string automationId = string.Empty; const string className = "yyy"; string txtValue = string.Empty; ControlType controlType = ControlType.Button; var ht1 = new Hashtable(); ht1.Add("controlType", "button"); ht1.Add("class", className); var ht2 = new Hashtable(); ht2.Add("controlType", "menu"); var inputData = new[] { ht1, ht2 }; TestParametersAgainstCollection( inputData, new [] { FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, "cl01", string.Empty), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, className, string.Empty), FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, "cl03", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.HeaderItem, string.Empty, string.Empty, className, string.Empty) }, false); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void ThreeCriteria_ThreeElements_NoMatch_NameAutomaitonIdClassName() { // Arrange var hashtable = new Hashtable(); hashtable.Add("NAME", "*aaa*"); hashtable.Add("AUTOMATIONID", "*id*"); hashtable.Add("CLASS", "cl*ss"); // Act bool result = RealCodeCaller.GetResult_IsStepActive( new Hashtable[] { hashtable }, AutomationFactory.GetUiEltCollection( new[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "aa1aa", "auId", "clas", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Button, "aa2aa3aa", "Id", "cl____s", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Button, "a4a5abbb", "iDrweqrqw", @"/ss", string.Empty) }) ); // Assert MbUnit.Framework.Assert.AreEqual(false, result); Assert.Equal(false, result); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get1of3_NoRecurison() { // Arrange const int pid = 555; TestParametersAgainstCollection( new[] { pid }, null, string.Empty, string.Empty, new IUiElement[] { FakeFactory.GetAutomationElementExpected( new ElementData { Current_ProcessId = pid, Current_ControlType = ControlType.Window }), FakeFactory.GetAutomationElementNotExpected( new ElementData { Current_ProcessId = 3, Current_ControlType = ControlType.Window }), FakeFactory.GetAutomationElementNotExpected( new ElementData { Current_ProcessId = 4, Current_ControlType = ControlType.Window }) }, 1); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void ThreeResults() { const string expectedName = "name"; HasTimeoutCmdletBase cmdlet = new HasTimeoutCmdletBase(); IFakeUiElement element01 = FakeFactory.GetAutomationElementExpected( ControlType.Button, expectedName, string.Empty, string.Empty, string.Empty); IFakeUiElement element02 = FakeFactory.GetAutomationElementExpected( ControlType.Button, expectedName, string.Empty, string.Empty, string.Empty); IFakeUiElement element03 = FakeFactory.GetAutomationElementExpected( ControlType.Button, string.Empty, string.Empty, string.Empty, string.Empty); IFakeUiElement element04 = FakeFactory.GetAutomationElementExpected( ControlType.Button, expectedName, string.Empty, string.Empty, string.Empty); var controlSearcherData = new ControlSearcherData { Name = expectedName, AutomationId = string.Empty, Class = string.Empty, Value = string.Empty }; List <IUiElement> resultList = WindowSearcher.ReturnOnlyRightElements( new[] { element01, element02, element03, element04 }, controlSearcherData, false, true); MbUnit.Framework.Assert.AreEqual(3, resultList.Count); // 20140312 // MbUnit.Framework.Assert.Exists(resultList, e => e.Current.Name == expectedName); // ?? MbUnit.Framework.Assert.Exists(resultList, e => e.GetCurrent().Name == expectedName); // ?? }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void WindowOpenedEvent() { // Arrange var element = FakeFactory.GetAutomationElementExpected(ControlType.Window, string.Empty, string.Empty, string.Empty, string.Empty); var cmdlet = new RegisterUiaWindowOpenedEventCommand { InputObject = new IUiElement[] { element } }; TestEvent( cmdlet); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void PropertyChangedEvent_ValuePattern_ValueProperty() { // Arrange var element = FakeFactory.GetAutomationElementExpected(ControlType.Window, string.Empty, string.Empty, string.Empty, string.Empty); var cmdlet = new RegisterUiaValueChangedEventCommand { InputObject = new IUiElement[] { element } // , }; TestEvent( cmdlet, ValuePattern.ValueProperty); }
private IUiElement[] GetCmdletInputObject_Three() { return(new [] { FakeFactory.GetElement_ForFindAll( new IUiElement [] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "name1", "automationId1", "className1", "value1"), FakeFactory.GetAutomationElementExpected(ControlType.Button, "name2", "automationId2", "className2", "value2"), FakeFactory.GetAutomationElementExpected(ControlType.Button, "name3", "automationId3", "className3", "value3"), }, new PropertyCondition( AutomationElement.ControlTypeProperty, ControlType.Button)) }); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get1of3_byContainsText_NameAutomationIdClass() { const string searchString = "str"; ControlType controlType = null; TestParametersAgainstCollection( controlType, searchString, new [] { FakeFactory.GetAutomationElementNotExpected(ControlType.Tab, "other name", string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Image, string.Empty, searchString, string.Empty, string.Empty), FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, "third class", string.Empty) }, 1); }
public void Get3of3_byName() { const string containsText = "*ame??atche*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "name matches", string.Empty, string.Empty, string.Empty, 10), FakeFactory.GetAutomationElementExpected(ControlType.Custom, "Name matches", string.Empty, string.Empty, string.Empty, 20), FakeFactory.GetAutomationElementExpected(ControlType.Hyperlink, "name matcheZ", string.Empty, string.Empty, string.Empty, 30) }, new int[] { 10, 20, 30 }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byContainsText_AutomationIdClassValue() { const string searchString = "str"; ControlType controlType = null; TestParametersAgainstCollection( controlType, searchString, new [] { FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, searchString, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Custom, string.Empty, string.Empty, searchString, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Hyperlink, string.Empty, string.Empty, string.Empty, searchString) }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byContainsTextControlType_ClassValue() { const string searchString = "str"; ControlType controlType = ControlType.Button; TestParametersAgainstCollection( controlType, searchString, new [] { FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, searchString), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, searchString, searchString), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, searchString) }, 3); }
public void Get1of3_byName() { const string containsText = "*ame??atche*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Tab, "other name", string.Empty, string.Empty, string.Empty, 10), FakeFactory.GetAutomationElementExpected(ControlType.Image, "name matches", string.Empty, string.Empty, string.Empty, 20), FakeFactory.GetAutomationElementExpected(ControlType.Button, "third name", string.Empty, string.Empty, string.Empty, 30) }, new int[] { 10, 20, 30 }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get1of3_byContainsTextControlType_Value() { const string searchString = "str"; ControlType controlType = ControlType.Button; TestParametersAgainstCollection( controlType, searchString, new [] { FakeFactory.GetAutomationElementNotExpected(ControlType.DataGrid, string.Empty, string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, searchString), FakeFactory.GetAutomationElementNotExpected(ControlType.DataItem, string.Empty, string.Empty, string.Empty, string.Empty) }, 1); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byAutomationId() { // Arrange const string containsText = "*au??id*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "name matches", "mauxyidz", string.Empty, string.Empty, 15), FakeFactory.GetAutomationElementExpected(ControlType.Custom, "Name matches", "AU23id", string.Empty, string.Empty, 30), FakeFactory.GetAutomationElementExpected(ControlType.Hyperlink, "name matcheZ", "au..ID", string.Empty, string.Empty, 45) }, new int[] { 15, 30, 45 }, 3); }
public void Get3of3_byControlTypeName() { const string containsText = "*ame??atche*"; ControlType controlType = ControlType.Button; TestParametersAgainstCollection( containsText, controlType.ConvertControlTypeToStringArray(), new IUiElement[] { FakeFactory.GetAutomationElementExpected(controlType, "name matches", string.Empty, string.Empty, string.Empty, 10), FakeFactory.GetAutomationElementExpected(controlType, "NNName matches", string.Empty, string.Empty, string.Empty, 20), FakeFactory.GetAutomationElementExpected(controlType, "name matcheZ", string.Empty, string.Empty, string.Empty, 30) }, new int[] { 10, 20, 30 }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get0of3_byName() { // Arrange const string containsText = "*ame??atche*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "other name", string.Empty, string.Empty, string.Empty, 15), FakeFactory.GetAutomationElementExpected(ControlType.Custom, "second name", string.Empty, string.Empty, string.Empty, 30), FakeFactory.GetAutomationElementExpected(ControlType.CheckBox, "third name", string.Empty, string.Empty, string.Empty, 45) }, new int[] { 15, 30, 45 }, 0); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byValue() { // Arrange const string containsText = "*va*lue*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Button, "name matches", "mauxyidz", "classname", "my value", 15), FakeFactory.GetAutomationElementExpected(ControlType.Custom, "Name matches", "AU23id", "class name", "the value", 30), FakeFactory.GetAutomationElementExpected(ControlType.Hyperlink, "name matcheZ", "au..ID", "clockname", "value", 45) }, new int[] { 15, 30, 45 }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get1of3_byValue() { // Arrange const string containsText = "*valu*"; TestParametersAgainstCollection( containsText, null, new IUiElement[] { FakeFactory.GetAutomationElementExpected(ControlType.Tab, "other name", "automationId", string.Empty, "value", 15), FakeFactory.GetAutomationElementExpected(ControlType.Image, "name matches", string.Empty, string.Empty, string.Empty, 30), FakeFactory.GetAutomationElementExpected(ControlType.Button, "third name", string.Empty, "className", string.Empty, 45) }, new int[] { 15, 30, 45 }, 1); }
public void Get0of4_byControlTypeName() { const string containsText = "*ame??atche*"; ControlType controlType = ControlType.Button; TestParametersAgainstCollection( containsText, controlType.ConvertControlTypeToStringArray(), new IUiElement[] { FakeFactory.GetAutomationElementExpected(controlType, "other name", string.Empty, string.Empty, string.Empty, 10), FakeFactory.GetAutomationElementExpected(controlType, "second name", string.Empty, string.Empty, string.Empty, 20), FakeFactory.GetAutomationElementExpected(controlType, "third name", string.Empty, string.Empty, string.Empty, 30), FakeFactory.GetAutomationElementNotExpected(ControlType.DataGrid, containsText, string.Empty, string.Empty, string.Empty, 40) }, new int[] { 10, 20, 30, 40 }, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void NoneCriteria_OneElement() { // Arrange var element = FakeFactory.GetAutomationElementExpected(ControlType.Button, "aaaa", string.Empty, string.Empty, string.Empty); // Act bool result = RealCodeCaller.GetResult_IsStepActive( new Hashtable[] { null }, AutomationFactory.GetUiEltCollection(new[] { element }) ); // Assert MbUnit.Framework.Assert.AreEqual(false, result); Assert.Equal(false, result); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_NoParam() { string name = string.Empty; string automationId = string.Empty; string className = string.Empty; string txtValue = string.Empty; // ControlType controlType = null; TestParametersAgainstCollection( new Hashtable[] {}, new [] { FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Custom, string.Empty, string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.TabItem, string.Empty, string.Empty, string.Empty, string.Empty) }, false); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get2of4_byControlTypeName() { // Arrange const string containsText = "*ame??atche*"; ControlType controlType = ControlType.Button; TestParametersAgainstCollection( containsText, controlType.ConvertControlTypeToStringArray(), new IUiElement[] { FakeFactory.GetAutomationElementExpected(controlType, "other name", string.Empty, string.Empty, string.Empty, 15), FakeFactory.GetAutomationElementExpected(controlType, "name matches", string.Empty, string.Empty, string.Empty, 30), FakeFactory.GetAutomationElementExpected(controlType, "third name", string.Empty, string.Empty, string.Empty, 45), FakeFactory.GetAutomationElementNotExpected(ControlType.Group, containsText, string.Empty, string.Empty, string.Empty, 60) }, new int[] { 15, 30, 45, 60 }, 2); }
public void Get1of1_Name() { // Arrange const int pid = 555; TestParametersAgainstCollection( new[] { pid }, new string[] { "aaaa" }, string.Empty, string.Empty, new IUiElement[] { FakeFactory.GetAutomationElementExpected( new ElementData { Current_ProcessId = pid, Current_ControlType = ControlType.Window }) }, 1); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void OneCriterion_OneElement_NoMatch_ClassName() { // Arrange var hashtable = new Hashtable(); hashtable.Add("class", "*aaa*"); var element = FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, "bbbb", string.Empty); // Act bool result = RealCodeCaller.GetResult_IsStepActive( new Hashtable[] { hashtable }, AutomationFactory.GetUiEltCollection(new[] { element }) ); // Assert MbUnit.Framework.Assert.AreEqual(false, result); Assert.Equal(false, result); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of4_byControlTypeClass_X5() { string name = string.Empty; string automationId = string.Empty; const string className = "yyy"; string txtValue = string.Empty; ControlType controlType = ControlType.Button; var ht1 = new Hashtable(); ht1.Add("controlType", "button"); ht1.Add("class", className); var ht2 = new Hashtable(); ht2.Add("controlType", "headeritem"); var ht3 = new Hashtable(); ht3.Add("controlType", "button"); ht3.Add("class", "cl03"); var ht4 = new Hashtable(); ht4.Add("controlType", "button"); ht4.Add("class", className); var ht5 = new Hashtable(); ht5.Add("controlType", "headeritem"); // Hashtable[] inputData = // new[] { ht1, ht2, ht3, ht4, ht5 }; Hashtable[] inputData = { ht1, ht2, ht3, ht4, ht5 }; TestParametersAgainstCollection( inputData, new [] { FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, "cl01", string.Empty), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, className, string.Empty), FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, "cl03", string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.HeaderItem, string.Empty, string.Empty, className, string.Empty) }, true); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void ThreeCriteria_OneElement_Match_NameAutomationIdClassName() { // Arrange var hashtable = new Hashtable(); hashtable.Add("NAME", "*aaa*"); hashtable.Add("AUTOMATIONID", "*id*"); hashtable.Add("CLASS", "cl*ss"); var element = FakeFactory.GetAutomationElementExpected(ControlType.Button, "aaaa", "auId", "class", string.Empty); // Act bool result = RealCodeCaller.GetResult_IsStepActive( new Hashtable[] { hashtable }, AutomationFactory.GetUiEltCollection(new[] { element }) ); // Assert MbUnit.Framework.Assert.AreEqual(true, result); Assert.Equal(true, result); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byValue_Regex() { string name = string.Empty; string automationId = string.Empty; string className = string.Empty; const string txtValue = "xxx"; const string expectedValue = @"(x\s?){3}"; ControlType controlType = null; TestParametersAgainstCollection( controlType, name, automationId, className, expectedValue, new [] { FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "xxxx"), FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, txtValue), FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "yx x x ") }, UsualWildcardRegex.Regex, 3); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get1of3_byValue_Wildcard() { string name = string.Empty; string automationId = string.Empty; string className = string.Empty; const string txtValue = "xxx"; const string expectedValue = "?x*"; ControlType controlType = null; TestParametersAgainstCollection( controlType, name, automationId, className, expectedValue, new [] { FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "value1"), FakeFactory.GetAutomationElementExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, txtValue), FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "value3") }, UsualWildcardRegex.Wildcard, 1); }
[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact] public void Get3of3_byName_Regex() { const string name = "aaa"; const string expectedName = "[a]{2,3}"; string automationId = string.Empty; string className = string.Empty; string txtValue = string.Empty; ControlType controlType = null; TestParametersAgainstCollection( controlType, expectedName, automationId, className, txtValue, new [] { FakeFactory.GetAutomationElementExpected(ControlType.Button, name, string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Custom, name, string.Empty, string.Empty, string.Empty), FakeFactory.GetAutomationElementExpected(ControlType.Hyperlink, name, string.Empty, string.Empty, string.Empty) }, UsualWildcardRegex.Regex, 3); }