[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);
        }
Ejemplo n.º 2
0
        [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);
        }
Ejemplo n.º 3
0
        private void TestParametersAgainstCollection(
            string containsText,
            string[] controlTypeNames,
            IEnumerable <IUiElement> collection,
            IEnumerable <int> handles,
            int expectedNumberOfElements)
        {
            // Act
            var resultList = RealCodeCaller.SearchByContainsTextViaWin32(FakeFactory.GetAutomationElementNotExpected(null, string.Empty, string.Empty, string.Empty, string.Empty), containsText, controlTypeNames, collection, handles);

            // Assert
            MbUnit.Framework.Assert.Count(expectedNumberOfElements, resultList);
            Assert.Equal(expectedNumberOfElements, resultList.Count);
        }
        [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);
        }
        [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 Get0of3_byContainsText_Value()
        {
            const string searchString = "str";
            ControlType  controlType  = null;

            TestParametersAgainstCollection(
                controlType,
                searchString,
                new [] {
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "other value"),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Custom, string.Empty, string.Empty, string.Empty, "second value"),
                FakeFactory.GetAutomationElementNotExpected(ControlType.CheckBox, string.Empty, string.Empty, string.Empty, "third value")
            },
                0);
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]//
        public void Get0of3_byContainsTextControlType_ThreeControlType()
        {
            const string searchString = "str";
            ControlType  controlType  = ControlType.Button;

            TestParametersAgainstCollection(
                controlType,
                searchString,
                new [] {
                FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty)
            },
                0);
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void Get0of3_NoParam_2()
        {
            string      searchString = string.Empty;
            ControlType controlType  = null;

            TestParametersAgainstCollection(
                controlType,
                searchString,
                new [] {
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, "name", string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Custom, string.Empty, "automation id", string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(ControlType.TabItem, string.Empty, string.Empty, "className", "value")
            },
                0);
        }
Ejemplo n.º 9
0
        public void Get1of4_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, "name matches", string.Empty, string.Empty, string.Empty, 20),
                FakeFactory.GetAutomationElementExpected(controlType, "third name", string.Empty, string.Empty, string.Empty, 30),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Group, 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 Get1of4_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, "second name", string.Empty, string.Empty, string.Empty, 30),
                FakeFactory.GetAutomationElementExpected(controlType, "third name", string.Empty, string.Empty, string.Empty, 45),
                FakeFactory.GetAutomationElementNotExpected(ControlType.DataGrid, containsText, string.Empty, string.Empty, string.Empty, 60)
            },
                new int[] { 15, 30, 45, 60 },
                1);
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void Get0of1_ClassName()
        {
            // Arrange
            const int pid = 555;

            TestParametersAgainstCollection(
                new[] { pid },
                null,
                string.Empty,
                "class",
                new IUiElement[] {
                FakeFactory.GetAutomationElementNotExpected(
                    new ElementData {
                    Current_ProcessId   = 1,
                    Current_ControlType = ControlType.Window
                })
            },
                0);
        }
Ejemplo n.º 12
0
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void OneCriterion_OneElement_NoMatch_AutomationId()
        {
            // Arrange
            var hashtable = new Hashtable();

            hashtable.Add("AUTOMATIONID", "*aaa*");
            var element = FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, "bbbb", string.Empty, 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 Get0of3_byValue_Regex()
        {
            string       name         = string.Empty;
            string       automationId = string.Empty;
            string       className    = string.Empty;
            const string txtValue     = "xxx";
            ControlType  controlType  = null;

            TestParametersAgainstCollection(
                controlType,
                name,
                automationId,
                className,
                txtValue,
                new [] {
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "value1"),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "value2"),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, string.Empty, string.Empty, string.Empty, "value3")
            },
                UsualWildcardRegex.Regex,
                0);
        }
Ejemplo n.º 14
0
        [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 Get1of3_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.GetAutomationElementNotExpected(ControlType.Tab, "other name", string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementExpected(ControlType.Image, name, string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, "third name", string.Empty, string.Empty, string.Empty)
            },
                UsualWildcardRegex.Regex,
                1);
        }
        [NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void Get0of3_byName_Wildcard()
        {
            // const string name = "aaa";
            const string expectedName = "*aa";
            string       automationId = string.Empty;
            string       className    = string.Empty;
            string       txtValue     = string.Empty;
            ControlType  controlType  = null;

            TestParametersAgainstCollection(
                controlType,
                expectedName,
                automationId,
                className,
                txtValue,
                new [] {
                FakeFactory.GetAutomationElementNotExpected(ControlType.Button, "other name", string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(ControlType.Custom, "second name", string.Empty, string.Empty, string.Empty),
                FakeFactory.GetAutomationElementNotExpected(ControlType.CheckBox, "third name", string.Empty, string.Empty, string.Empty)
            },
                UsualWildcardRegex.Wildcard,
                0);
        }