Exemplo n.º 1
0
        public void CreateData()
        {
            var mainWindow = Application.GetMainWindow(Automation);

            Assert.That(mainWindow, Is.Not.Null);

            var cf = new ConditionFactory(new UIA3PropertyLibrary());

            var defPath     = Path.Combine(projectDataFolder, "Definitions", "TestStructure.xmldef");
            var defContents = @"
<Definitions xmlns:meta=""Editor"">
	<Definition Name=""MyAwesomeData"" meta:RefKey=""Struct"">
		<Data Name=""IsAwesome"" meta:RefKey=""Boolean"" />
		<Data Name=""Description"" meta:RefKey=""String"" />
	</Definition>
</Definitions>".Trim();

            File.WriteAllText(defPath, defContents);
            Thread.Sleep(1000);

            var dataPath = Path.Combine(projectDataFolder, "SuperData.xml");

            // create new data file
            FindAndClick(mainWindow, cf.ByText("New MyAwesomeData File..."));
            Thread.Sleep(SleepTime);

            Keyboard.Type(dataPath);
            Thread.Sleep(SleepTime);

            FindAndClickButton(mainWindow, cf.ByText("Save"));
            Thread.Sleep(SleepTime);

            // get tools refs
            var focusTool = mainWindow.FindFirstDescendant(cf.ByClassName("FocusToolView"));

            Assert.That(focusTool, Is.Not.Null);

            var documentView = mainWindow.FindFirstDescendant(cf.ByClassName("DocumentView"));

            Assert.That(documentView, Is.Not.Null);

            // fill in data
            var nameBox = GetEditorForItem(cf, documentView, "TextBox", 0);

            nameBox.AsTextBox().Text = "This is some awesome data that I made";

            GetEditorForItem(cf, documentView, "CheckBox", 0).AsCheckBox().IsChecked = true;
            Thread.Sleep(SleepTime);

            // save and close
            FindAndClickButton(mainWindow, cf.ByHelpText("Save the current file"));
            Thread.Sleep(SleepTime);

            FindAndClickButton(mainWindow, cf.ByHelpText("Close"));
            Thread.Sleep(SleepTime);

            var dataContents = File.ReadAllText(dataPath);

            var expected = @"
<MyAwesomeData xmlns:meta=""Editor"">
	<IsAwesome>true</IsAwesome>
	<Description>This is some awesome data that I made</Description>
</MyAwesomeData>".Trim();

            Assert.That(dataContents, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void CreateDefinition()
        {
            var mainWindow = Application.GetAllTopLevelWindows(Automation)[0];

            Assert.That(mainWindow, Is.Not.Null);

            var cf = new ConditionFactory(new UIA3PropertyLibrary());

            var defPath = Path.Combine(projectDataFolder, "Definitions", "TestStructure.xmldef");

            if (File.Exists(defPath))
            {
                File.Delete(defPath);
                Thread.Sleep(1000);
            }

            // create def file
            FindAndClickHyperlink(mainWindow, cf.ByText("New Definition..."));
            Thread.Sleep(SleepTime);

            Keyboard.Type("TestStructure");
            Thread.Sleep(SleepTime);

            FindAndClickButton(mainWindow, cf.ByText("Save"));
            Thread.Sleep(SleepTime);

            // get tools
            var focusTool = mainWindow.FindFirstDescendant(cf.ByClassName("FocusToolView"));

            Assert.That(focusTool, Is.Not.Null);

            var documentView = mainWindow.FindFirstDescendant(cf.ByClassName("DocumentView"));

            Assert.That(documentView, Is.Not.Null);

            // fill in file

            // create struct
            FindAndClickButton(documentView, cf.ByHelpText("Add new item"));
            Thread.Sleep(SleepTime);
            FindAndClickButton(documentView, cf.ByHelpText("Create"));
            Thread.Sleep(SleepTime);
            FindLastAndClickButton(documentView, cf.ByHelpText("Attributes"));
            Thread.Sleep(SleepTime);

            var nameBox = GetEditorForItem(cf, focusTool, "TextBox", 0).AsTextBox();

            Assert.That(nameBox.Text, Is.EqualTo("Struct"));
            nameBox.Text = "MyAwesomeData";
            nameBox.Click();
            Thread.Sleep(SleepTime);

            // create boolean child
            FindLastAndClickButton(documentView, cf.ByHelpText("Add new item"));
            Thread.Sleep(SleepTime);

            FindAndClick(documentView, cf.ByText("Name=MyAwesomeData"));
            Thread.Sleep(SleepTime);

            FindLastAndClickButton(documentView, cf.ByHelpText("Create"));
            Thread.Sleep(SleepTime);

            FindLastAndClickButton(documentView, cf.ByHelpText("Attributes"));
            Thread.Sleep(SleepTime);

            nameBox = GetEditorForItem(cf, focusTool, "TextBox", 0).AsTextBox();
            Assert.That(nameBox.Text, Is.EqualTo("Boolean"));
            nameBox.Text = "IsAwesome";
            nameBox.Click();
            Thread.Sleep(SleepTime);

            // create string child
            FindLastAndClickButton(documentView, cf.ByHelpText("Add new item"));
            Thread.Sleep(SleepTime);

            FindAndClick(documentView, cf.ByClassName("ComboBox"));
            Thread.Sleep(SleepTime);

            FindAndClick(mainWindow.Popup, cf.ByText("String"));
            Thread.Sleep(SleepTime);

            FindLastAndClickButton(documentView, cf.ByHelpText("Create"));
            Thread.Sleep(SleepTime);

            FindLastAndClickButton(documentView, cf.ByHelpText("Attributes"));
            Thread.Sleep(SleepTime);

            nameBox = GetEditorForItem(cf, focusTool, "TextBox", 0).AsTextBox();
            Assert.That(nameBox.Text, Is.EqualTo("String"));
            nameBox.Text = "Description";
            nameBox.Click();
            Thread.Sleep(SleepTime);

            // save and close
            FindAndClickButton(mainWindow, cf.ByHelpText("Save the current file"));
            Thread.Sleep(SleepTime);

            FindAndClickButton(mainWindow, cf.ByHelpText("Close"));
            Thread.Sleep(SleepTime);

            var defContents = File.ReadAllText(defPath);

            var expected = @"
<Definitions xmlns:meta=""Editor"">
	<Definition Name=""MyAwesomeData"" meta:RefKey=""Struct"">
		<Data Name=""IsAwesome"" meta:RefKey=""Boolean"" />
		<Data Name=""Description"" meta:RefKey=""String"" />
	</Definition>
</Definitions>".Trim();

            Assert.That(defContents, Is.EqualTo(expected));
        }