Exemplo n.º 1
0
        public static bool SaveToModelFile(TestObjectNurse rootNurse, string filePath)
        {
            AppModel model = new AppModel();

            foreach (TestObjectNurse nurseObject in rootNurse.Children)
            {
                ITestObject testObject = nurseObject.TestObject;

                model.Add(testObject);
            }

            try
            {
                WatcherEnable = false;
                AppModelManager.Save(model, filePath);

                EnsureWatcherCreated(filePath);
                AppEnvironment.CurrentModelPath = filePath;
            }
            finally
            {
                WatcherEnable = true;
            }

            return(true);
        }
Exemplo n.º 2
0
        public void UIATestObject_NoCachedProperties()
        {
            AppModel    model      = AppModelManager.Load("UnitTestObjectModel1.json", ModelLoadLevel.ReplayOnly);
            ITestObject testObject = model.FindFirst(o => o.NodeName == "CachedPropertyTestNode");

            CachedPropertyGroup cachedObject = testObject.GetContext <CachedPropertyGroup>();

            Assert.AreEqual(null, cachedObject);
        }
Exemplo n.º 3
0
        public void AppModelManager_Save()
        {
            string   filePath = "CalcAppModel.json";
            string   content  = Utility.ReadFileContent(filePath);
            AppModel model    = JsonUtil.DeserializeObject <AppModel>(content);

            AppModelManager.Save(model, "CalcAppModel2.json");

            Assert.IsTrue(model.ModelFile.FilePath.EndsWith("CalcAppModel2.json"));
            //TODO validate the content
        }
Exemplo n.º 4
0
        public void UIATestObject_CachedProperties()
        {
            AppModel    model      = AppModelManager.Load("UnitTestObjectModel1.json", ModelLoadLevel.Full);
            ITestObject testObject = model.FindFirst(o => o.NodeName == "CachedPropertyTestNode");

            CachedPropertyGroup cachedObject = testObject.GetContext <CachedPropertyGroup>();

            Assert.AreNotEqual(null, cachedObject);

            Assert.AreEqual("asdfasfdasdfasdf.png", cachedObject.Properties["imageFile"]);
        }
Exemplo n.º 5
0
        public void AppModelManager_LoadFull()
        {
            AppModel       model;
            ModelLoadLevel loadLevel = ModelLoadLevel.Full;

            model = AppModelManager.Load("CalcAppModel.json", loadLevel);
            UIATestObject testObject = (UIATestObject)model.FindFirst(DescriptorKeys.NodeName, "result");

            Assert.AreNotEqual(null, testObject);
            UIACondition condition = testObject.GetContext <UIACondition>();

            //TODO validate the content
        }
Exemplo n.º 6
0
        public void AppModelManager_LoadReplayOnly()
        {
            AppModel model;

            //default is replay only
            model = AppModelManager.Load("CalcAppModel.json");
            ITestObject resultObject = model.FindFirst(DescriptorKeys.NodeName, "result");

            Assert.AreNotEqual(null, resultObject);

            Assert.IsNotNull(model.ModelFile);

            Assert.IsTrue(model.ModelFile.FilePath.EndsWith("CalcAppModel.json", StringComparison.InvariantCultureIgnoreCase));
            //TODO: do some more validation on the content
        }
        public void VirtualControlHelper_LoadVirtualControls()
        {
            string   appModelPath = "UnitTestVirtualControl.json";
            AppModel virtualModel = AppModelManager.Load(appModelPath);

            Assert.AreEqual(1, virtualModel.Items.Count);

            ITestObject testObject = virtualModel.Items[0];

            Assert.AreEqual(3, testObject.Children.Count);

            VirtualTestObject[] controls = VirtualControlHelper.GetVirtualControls(testObject);

            VirtualControlHelper.DumpVirtualControls(controls);
        }
Exemplo n.º 8
0
        public static AppModel LoadModelFile(string appModelPath, TestObjectNurse rootNurse)
        {
            _treeObjects = rootNurse.TreeView;

            AppModel model = AppModelManager.Load(appModelPath, ModelLoadLevel.Full);

            TestObjectToTreeNode(model.Items, rootNurse);

            AppEnvironment.CurrentModelPath = appModelPath;

            OnFileLoaded(appModelPath);

            AppEnvironment.CurrentModelPath = appModelPath;
            EnsureWatcherCreated(AppEnvironment.CurrentModelPath);

            return(model);
        }
Exemplo n.º 9
0
        public void AppModelManager_LoadFileMissing()
        {
            AppModel model;

            try
            {
                model = AppModelManager.Load("SomeFileDoesntExist.json");

                Assert.IsNull(model.ModelFile);
            }
            catch (FileNotFoundException ex)
            {
                Assert.IsTrue(true);
                return;
            }
            Assert.Fail("Should throw FileNotFoundException if file doesn't exist");
        }
Exemplo n.º 10
0
        public void AppModelManager_HierarchySave()
        {
            UIATestObject d1 = new UIATestObject()
            {
                NodeName    = "rootWindow1",
                ControlName = "rootWindow1_controlName",
                ControlType = ControlType.Window,
                Description = "this is root window"
            };
            UIATestObject d2 = new UIATestObject()
            {
                ControlName = "Panel1",
                ControlType = ControlType.TitleBar
            };
            UIATestObject d3 = new UIATestObject()
            {
                ControlName = "Button",
                ControlType = ControlType.Tree
            };

            /*                    {
             *          {"name", "Button1"},
             *          {"index", "0"},
             *          {"helpText", "Some help Text"}
             *      };
             *
             * d3.AddProperty("name", "Button1");
             * d3.AddProperty("index", "0");
             * d3.AddProperty("helpText", "Some help Text");
             */
            UIATestObject d4 = new UIATestObject()
            {
                ControlType = ControlType.Text
            };

            d4.AddProperty("id", "Text1");

            /*
             * d4.SetItem<UIAPropertyItem>(new UIAPropertyItem()
             * {
             *  Properties = new PropertyEntry()
             *      {
             *          {"id", "Text1"}
             *      }
             * });*/

            d1.AddChild(d2);
            d2.AddChild(d4);

            d2.AddChild(d3);
            AppModel model = new AppModel()
            {
                ProcessName = "calc.exe"
            };

            model.Add(d1);

            AppModelManager.Save(model, "CalcAppModel3.json");

            TestUtility.LaunchNotepad(Path.Combine(System.Environment.CurrentDirectory, "CalcAppModel3.json"));
            //TODO validate the content
        }
Exemplo n.º 11
0
        public static UIAModel GetManager(string pathToModel)
        {
            AppModel model = AppModelManager.Load(pathToModel);

            return(new UIAModel(model));
        }