Example #1
0
        /// <summary>
        /// Init core classes type dictionary for RepositorySerializer
        /// </summary>
        void InitClassTypesDictionary()
        {
            if (bDone)
            {
                return;
            }
            bDone = true;

            // Add all RI classes from GingerCoreCommon
            NewRepositorySerializer.AddClassesFromAssembly(typeof(RepositoryItemBase).Assembly);

            // Add gingerCoreNET classes
            NewRepositorySerializer.AddClassesFromAssembly(typeof(RunSetConfig).Assembly);
            NewRepositorySerializer.AddClassesFromAssembly(typeof(ALMConfig).Assembly);
        }
Example #2
0
        public void VerifySerialzedAttrDefaultValueWithChange()
        {
            //Arrange
            BusinessFlow BF = new BusinessFlow("BF2");

            BF.Source = BusinessFlow.eSource.Gherkin;

            //Act
            string       xml = RS.SerializeToString(BF);
            BusinessFlow BF2 = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(xml);

            //Assert
            Assert.AreEqual(BF.Source, BusinessFlow.eSource.Gherkin);
            Assert.AreEqual(BF.Active, BF2.Active);
        }
Example #3
0
        //[Timeout(60000)]
        public void BusinessFlowBrowserActionTest()
        {
            //Arrange
            //Put the BF in Test Resource
            NewRepositorySerializer RepositorySerializer = new NewRepositorySerializer();

            string FileName = TestResources.GetTestResourcesFile($"XML{Separator}Flow 1.Ginger.BusinessFlow.xml");

            //Load BF
            BusinessFlow businessFlow = (BusinessFlow)RepositorySerializer.DeserializeFromFile(FileName);

            //Asert
            Assert.AreEqual("GotoURL", (from aiv in businessFlow.Activities[0].Acts[0].InputValues where aiv.Param == "ControlAction" select aiv).FirstOrDefault().Value);
            Assert.AreEqual("NewTab", (from aiv in businessFlow.Activities[0].Acts[0].InputValues where aiv.Param == "GotoURLType" select aiv).FirstOrDefault().Value);
        }
Example #4
0
        public void DSConditionClassSkipSerializeTest()
        {
            //Arrange
            //Put the BF in Test Resource having class "GingerCore.DataSource.ActDSConditon" serialized in xml
            NewRepositorySerializer RepositorySerializer = new NewRepositorySerializer();
            string FileName = TestResources.GetTestResourcesFile(@"Repository" + Path.DirectorySeparatorChar + "DS_SkipWhereConditions_Flow.Ginger.BusinessFlow.xml");

            //Load BF
            BusinessFlow businessFlow = (BusinessFlow)RepositorySerializer.DeserializeFromFile(FileName);


            //Assert
            Assert.AreEqual(2, businessFlow.Activities.Count, "BF Activities Count");
            Assert.AreEqual(1, businessFlow.Activities[0].Acts.Count, "Activity Actions Count");
        }
Example #5
0
        public static Solution LoadSolution(string solutionFileName, bool startDirtyTracking = true, string encryptionKey = null)
        {
            string   txt      = File.ReadAllText(solutionFileName);
            Solution solution = (Solution)NewRepositorySerializer.DeserializeFromText(txt);

            solution.FilePath      = solutionFileName;
            solution.Folder        = Path.GetDirectoryName(solutionFileName);
            solution.EncryptionKey = encryptionKey ?? GetEncryptionKey(solution.Guid.ToString());
            if (startDirtyTracking)
            {
                solution.StartDirtyTracking();
            }
            //solution.SolutionOperations = this;
            return(solution);
        }
Example #6
0
        public static Solution LoadSolution(string solutionFileName, bool startDirtyTracking = true)
        {
            string txt = File.ReadAllText(solutionFileName);

            txt = txt.Replace("Ginger.Environments.Solution", "Ginger.SolutionGeneral.Solution");//changed the namespace so need to handle old xml's
            Solution solution = (Solution)NewRepositorySerializer.DeserializeFromText(txt);

            solution.FilePath = solutionFileName;
            solution.Folder   = Path.GetDirectoryName(solutionFileName);
            if (startDirtyTracking)
            {
                solution.StartDirtyTracking();
            }
            return(solution);
        }
Example #7
0
        public void UpdateRepositoryItem()
        {
            //Arrange
            NewRepositorySerializer RepositorySerializer = new NewRepositorySerializer();
            MyRepositoryItem        MRI2 = (from x in mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>() where x.Name == "A2" select x).FirstOrDefault();

            //Act
            MRI2.Name = "A2 New Name";
            mSolutionRepository.SaveRepositoryItem(MRI2);
            MyRepositoryItem MRI2FromDisk = (MyRepositoryItem)RepositorySerializer.DeserializeFromFile(MRI2.FilePath);


            //Assert
            Assert.AreEqual(MRI2.Guid, MRI2FromDisk.Guid);
            Assert.AreEqual(MRI2.Name, MRI2FromDisk.Name);
        }
        private void DoUpgrade(string backupFolder)
        {
            NewRepositorySerializer newSerilizer = new NewRepositorySerializer();

            mFailedFiles = new List <string>();

            // now do the upgrade file by file
            foreach (string filePathToConvert in mFilesToShow)
            {
                string filePath = filePathToConvert;
                //remove info extension
                if (filePath.Contains("-->"))
                {
                    filePath = filePath.Remove(filePath.IndexOf("-->"));
                }

                //do upgrade
                try
                {
                    //first copy to backup folder
                    string BakFile = filePath.Replace(mSolutionFolder, backupFolder);
                    MakeSurePathExistforBakFile(BakFile);
                    System.IO.File.Copy(filePath, BakFile, true);

                    //make sure backup was created
                    if (File.Exists(BakFile) == true)
                    {
                        //Do Upgrade by unserialize and serialize the item using new serializer
                        //unserialize
                        string             itemXML    = File.ReadAllText(filePath);
                        RepositoryItemBase itemObject = (RepositoryItemBase)NewRepositorySerializer.DeserializeFromText(itemXML);
                        itemObject.FilePath = filePath;
                        //serialize
                        newSerilizer.SaveToFile(itemObject, filePath);
                    }
                    else
                    {
                        mFailedFiles.Add(filePathToConvert);
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to upgrade the solution file '{0}'", filePath), ex);
                    mFailedFiles.Add(filePathToConvert);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Pull and return the Ginger Version (in String format) which the Solution file was created with
        /// </summary>
        /// <param name="xmlFilePath"></param>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static string GetSolutonFileGingerVersion(string xmlFilePath, string xml = "")
        {
            string fileVersion;

            //get the XML if needed
            if (string.IsNullOrEmpty(xml))
            {
                using (StreamReader reader = new StreamReader(xmlFilePath))
                {
                    //get XML
                    reader.ReadLine();                              //no need first line
                    xml = reader.ReadLine();
                    if (xml.ToLower().Contains("version") == false) //to handle new line gap in some old xml's
                    {
                        xml = reader.ReadLine();
                    }
                }
            }

            //get the version based on XML type (new/old repository item type)
            if (string.IsNullOrEmpty(xml) == false)
            {
                if (RepositorySerializer.IsLegacyXmlType(xml) == true)
                {
                    fileVersion = RepositorySerializer.GetXMLGingerVersion(xml, xmlFilePath);
                    if (fileVersion == "3.0.0.0")
                    {
                        fileVersion = fileVersion + "Beta";
                    }
                }
                else
                {
                    fileVersion = NewRepositorySerializer.GetXMLGingerVersion(xml, xmlFilePath);//New XML type
                }

                if (fileVersion == null)
                {
                    Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to get the Ginger Version of the file: '{0}'", xmlFilePath));
                }
                return(fileVersion);
            }
            else
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to get the Ginger Version of the file: '{0}'", xmlFilePath));
                return(null);
            }
        }
Example #10
0
        public void RepositoryItemKey()
        {
            //Arrange
            ApplicationPOMModel POM = new ApplicationPOMModel();

            POM.Name = "POM1";
            RepositoryItemKey key = POM.Key;

            //Act
            string xml = RS.SerializeToString(POM);
            ApplicationPOMModel POM2 = (ApplicationPOMModel)NewRepositorySerializer.DeserializeFromText(xml);

            //Assert
            Assert.AreEqual(POM.Name, POM2.Name);
            Assert.AreEqual(key.Guid, POM2.Key.Guid);
            Assert.AreEqual(key.ItemName, POM2.Key.ItemName);
        }
Example #11
0
        public void GetItemsInfo()
        {
            if (!mLazyLoad)
            {
                return;
            }
            if (loadingata) // //since several functions can call in parallel we might enter when status is already loadingdata, so we wait for it to complete, then return
            {
                int count = 0;
                while (loadingata && count < 1000)  // Max 10 seconds
                {
                    Thread.Sleep(10);
                    count++;
                }
                return;
            }

            //since several function can try to get data we need to lock and verify before we convert
            lock (this)
            {
                loadingata = true;
                // We need 2nd check as it might changed after lock released

                if (!mLazyLoad)
                {
                    return;               //since several functions can try to get data we need to lock and verify before we convert
                }
                //Option 1
                string s = mStringData;

                // Option 2
                // string s = StringCompressor.DecompressString(mStringData);

                //Option 3
                // string s = StringCompressor.DecompressStringFromBytes(mMemoryStream, mDataLen);

                ObservableList <T> l = new ObservableList <T>();
                NewRepositorySerializer.DeserializeObservableListFromText(this, s);

                mStringData = null;
                //mMemoryStream.Dispose();
                //mMemoryStream = null;
                mLazyLoad  = false;
                loadingata = false;
            }
        }
Example #12
0
        public void ActivitiesClearBackup()
        {
            //Arrange
            BusinessFlow BF       = new BusinessFlow();
            string       FileName = TestResources.GetTempFile("activityClearBackup.xml");

            BF.Name        = "Businessflow1";
            BF.Description = "Test Clear Backup";
            BF.Activities  = new ObservableList <Activity>();
            Activity a = new Activity()
            {
                ActivityName = "Activity 1", Description = "Desciption -1", Status = eRunStatus.Passed
            };

            BF.Activities.Add(a);

            ActTextBox t = new ActTextBox()
            {
                Description = "Set text box ", LocateBy = eLocateBy.ByID, LocateValue = "ID"
            };

            a.Acts.Add(t);

            //Act
            BF.RepositorySerializer.SaveToFile(BF, FileName);
            a.SaveBackup();
            ActGotoURL g = new ActGotoURL()
            {
                Description = "goto URL ", LocateValue = "ID"
            };

            a.Acts.Add(g);
            BF.RepositorySerializer.SaveToFile(BF, FileName);
            a.SaveBackup();
            a.RestoreFromBackup();

            NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
            BusinessFlow            BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), FileName);

            BF2.SaveBackup(); //dirty now just indicate if backup exist
            BF2.Description = "aaa";

            // Assert
            Assert.AreEqual(BF2.Activities[0].Acts.Count, BF.Activities[0].Acts.Count);
        }
        public static void ClassInitialize(TestContext TC)
        {
            string TempSolutionFolder = TestResources.GetTestTempFolder(@"Solutions\APIModelsTest");

            if (Directory.Exists(TempSolutionFolder))
            {
                Directory.Delete(TempSolutionFolder, true);
            }
            SR = GingerSolutionRepository.CreateGingerSolutionRepository();


            SR.CreateRepository(TempSolutionFolder);

            NewRepositorySerializer RS = new NewRepositorySerializer();

            NewRepositorySerializer.AddClassesFromAssembly(typeof(ApplicationAPIModel).Assembly);
            SR.Open(TempSolutionFolder);
        }
Example #14
0
        public static void ClassInitialize(TestContext TC)
        {
            string TempSolutionFolder = TestResources.GetTestTempFolder(@"Solutions" + Path.DirectorySeparatorChar + "APIModelsTest");

            if (Directory.Exists(TempSolutionFolder))
            {
                Directory.Delete(TempSolutionFolder, true);
            }
            SR = GingerSolutionRepository.CreateGingerSolutionRepository();


            SR.CreateRepository(TempSolutionFolder);

            NewRepositorySerializer RS = new NewRepositorySerializer();

            NewRepositorySerializer.AddClassesFromAssembly(NewRepositorySerializer.eAssemblyType.GingerCoreCommon);
            SR.Open(TempSolutionFolder);
        }
Example #15
0
        public void SolutionRecoverStart(bool showRecoverPageAnyway = false)
        {
            ObservableList <RecoveredItem> recovredItems = new ObservableList <RecoveredItem>();

            if (Directory.Exists(mRecoverFolderPath))
            {
                NewRepositorySerializer serializer = new NewRepositorySerializer();

                foreach (var directory in new DirectoryInfo(mRecoverFolderPath).GetDirectories())
                {
                    string timestamp = directory.Name.ToString().Replace("AutoSave_", string.Empty);

                    IEnumerable <FileInfo> files = directory.GetFiles("*", SearchOption.AllDirectories);

                    foreach (FileInfo file in files)
                    {
                        try
                        {
                            RecoveredItem recoveredItem = new RecoveredItem();
                            recoveredItem.RecoveredItemObject                  = serializer.DeserializeFromFile(file.FullName);
                            recoveredItem.RecoverDate                          = timestamp;
                            recoveredItem.RecoveredItemObject.FileName         = file.FullName;
                            recoveredItem.RecoveredItemObject.ContainingFolder = file.FullName.Replace(directory.FullName, "~");
                            recoveredItem.Status = eRecoveredItemStatus.PendingRecover;
                            recovredItems.Add(recoveredItem);
                        }
                        catch (Exception ex)
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to fetch recover item : " + file.FullName, ex);
                        }
                    }
                }

                if (recovredItems.Count == 0)
                {
                    CleanUp(); //have empty folders
                }
            }

            if (recovredItems.Count > 0 || showRecoverPageAnyway)
            {
                RepositoryItemHelper.RepositoryItemFactory.ShowRecoveryItemPage(recovredItems);
            }
        }
Example #16
0
        public void SaveLoadRunSetWithRunSetActionSendFreeEmailX2()
        {
            //Arrange

            //string FileName = Common.getGingerUnitTesterTempFolder() + @"RSC.Ginger.RunSetConfig.xml";

            RunSetConfig RSC = new RunSetConfig();

            RSC.RunSetActions.Add(new RunSetActionSendFreeEmail());
            RSC.RunSetActions.Add(new RunSetActionSendFreeEmail());
            // RSC.RunSetActions.Add(new RunSetActionSendEmail());

            string s = RS.SerializeToString(RSC);
            //Act
            RunSetConfig RSC2 = (RunSetConfig)NewRepositorySerializer.DeserializeFromText(s);

            //Assert
            Assert.AreEqual(RSC.RunSetActions.Count, RSC2.RunSetActions.Count);
        }
Example #17
0
        public static void ClassInitialize(TestContext TC)
        {
            string TempSolutionFolder = TestResources.getGingerUnitTesterTempFolder(@"Solutions\APIModelsTest");

            if (Directory.Exists(TempSolutionFolder))
            {
                Directory.Delete(TempSolutionFolder, true);
            }
            SR = new SolutionRepository();

            SR.AddItemInfo <ApplicationAPIModel>("*.Ginger.ApplicationAPIModel.xml", @"~\Applications Models\API Models", true, "API Models", PropertyNameForFileName: nameof(ApplicationAPIModel.Name));
            // SR.AddItemInfo<GlobalAppModelParameter>("*.Ginger.GlobalAppModelParameter.xml", @"~\Applications Models\Global Models Parameters", true, "Global Model Parameters", addToRootFolders: true, PropertyNameForFileName: nameof(GlobalAppModelParameter.PlaceHolder));

            SR.CreateRepository(TempSolutionFolder);

            NewRepositorySerializer RS = new NewRepositorySerializer();

            NewRepositorySerializer.AddClassesFromAssembly(typeof(ApplicationAPIModel).Assembly);
            SR.Open(TempSolutionFolder);
        }
Example #18
0
        public void LoadLazyInfo()
        {
            if (!LazyLoad)
            {
                return;
            }
            if (loadingata) // //since several functions can call in parallel we might enter when status is already loadingdata, so we wait for it to complete, then return
            {
                int count = 0;
                while (loadingata && count < 1000)  // Max 10 seconds
                {
                    Thread.Sleep(10);
                    count++;
                }
                return;
            }

            //since several function can try to get data we need to lock and verify before we convert
            lock (this)
            {
                loadingata = true;
                // We need 2nd check as it might changed after lock released
                if (!LazyLoad)
                {
                    return;              //since several functions can try to get data we need to lock and verify before we convert
                }
                try
                {
                    NewRepositorySerializer.DeserializeObservableListFromText(this, LazyLoadDetails.DataAsString);
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to Deserialize the lazy load list '{0}' from file '{1}'", LazyLoadDetails.Config.ListName, LazyLoadDetails.XmlFilePath), ex);
                }

                LazyLoadDetails.DataAsString  = null;
                LazyLoadDetails.DataWasLoaded = true;
                loadingata     = false;
                mAvoidLazyLoad = true;
            }
        }
        //[Timeout(60000)]
        public void AnalyzeBusinessFlowTest()
        {
            //Arrange
            //Put the BF in Test Resource
            NewRepositorySerializer RepositorySerializer = new NewRepositorySerializer();

            string FileName = TestResources.GetTestResourcesFile(@"Solutions" + Path.DirectorySeparatorChar + "AnalyzerTestSolution" + Path.DirectorySeparatorChar + "BusinessFlows" + Path.DirectorySeparatorChar + "Demo Flow 01.Ginger.BusinessFlow.xml");

            //Load BF
            BusinessFlow businessFlow = (BusinessFlow)RepositorySerializer.DeserializeFromFile(FileName);

            ObservableList <AnalyzerItemBase> mIssues = new ObservableList <AnalyzerItemBase>();
            AnalyzerUtils mAnalyzerUtils = new AnalyzerUtils();

            WorkSpace.Instance.SolutionRepository = SR;

            //Run Analyzer
            mAnalyzerUtils.RunBusinessFlowAnalyzer(businessFlow, mIssues);
            //Asert
            Assert.AreNotEqual(0, mIssues.Count);
        }
Example #20
0
        public void SaveLoadRunSetWithRunSetActionSendFreeEmailValidateEmail()
        {
            //Arrange
            //string FileName = Common.getGingerUnitTesterTempFolder() + @"RSC2.Ginger.RunSetConfig.xml";

            RunSetConfig RSC = new RunSetConfig();
            RunSetActionSendFreeEmail RAFE = new RunSetActionSendFreeEmail();

            RAFE.Email.MailTo = "meme";
            RSC.RunSetActions.Add(RAFE);

            string s = RS.SerializeToString(RSC);

            //Act
            RunSetConfig RSC2 = (RunSetConfig)NewRepositorySerializer.DeserializeFromText(s);
            RunSetActionSendFreeEmail RAFE2 = (RunSetActionSendFreeEmail)RSC2.RunSetActions[0];

            //Assert
            Assert.AreEqual(1, RSC2.RunSetActions.Count);
            Assert.AreEqual("meme", RAFE2.Email.MailTo);
        }
Example #21
0
        public void BizFlowClearBackup()
        {
            //Arrange
            BusinessFlow BF = new BusinessFlow();

            BF.Name        = "Businessflow1";
            BF.Description = "Test Clear Backup";
            BF.Activities  = new ObservableList <Activity>();

            Activity a = new Activity()
            {
                ActivityName = "Activity 1", Description = "Desciption -1", Status = eRunStatus.Passed
            };

            BF.Activities.Add(a);

            BF.SaveBackup();
            Activity b = new Activity()
            {
                ActivityName = "Activity 2", Description = "Desciption -2", Status = eRunStatus.Passed
            };

            BF.Activities.Add(b);

            string TempFilepath = TestResources.GetTempFile("bfClearBackup.xml");

            //Act
            BF.RepositorySerializer.SaveToFile(BF, TempFilepath);
            BF.SaveBackup();
            BF.RestoreFromBackup();

            NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
            BusinessFlow            BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), TempFilepath);

            BF2.SaveBackup();//dirty now just indicate if backup exist
            BF2.Description = "aaa";

            // Assert
            Assert.AreEqual(BF2.Activities.Count, BF.Activities.Count);
        }
Example #22
0
        public void SolutionRecoverStart(bool showRecoverPageAnyway = false)
        {
            ObservableList <RecoveredItem> recovredItems = new ObservableList <RecoveredItem>();

            if (Directory.Exists(mRecoverFolderPath))
            {
                NewRepositorySerializer serializer = new NewRepositorySerializer();

                foreach (var directory in new DirectoryInfo(mRecoverFolderPath).GetDirectories())
                {
                    string timestamp = directory.Name.ToString().Replace("AutoSave_", string.Empty);

                    IEnumerable <FileInfo> files = directory.GetFiles("*", SearchOption.AllDirectories);

                    foreach (FileInfo file in files)
                    {
                        RecoveredItem recoveredItem = new RecoveredItem();
                        recoveredItem.RecoveredItemObject                  = serializer.DeserializeFromFile(file.FullName);
                        recoveredItem.RecoverDate                          = timestamp;
                        recoveredItem.RecoveredItemObject.FileName         = file.FullName;
                        recoveredItem.RecoveredItemObject.ContainingFolder = file.FullName.Replace(directory.FullName, "~");
                        recoveredItem.Status = eRecoveredItemStatus.PendingRecover;
                        recovredItems.Add(recoveredItem);
                    }
                }

                if (recovredItems.Count == 0)
                {
                    CleanUp(); //have empty folders
                }
            }

            //show recover page
            if (recovredItems.Count > 0 || showRecoverPageAnyway)
            {
                RecoverPage recoverPage = new SolutionAutoSaveAndRecover.RecoverPage(recovredItems);
                recoverPage.ShowAsWindow(eWindowShowStyle.Dialog);
            }
        }
Example #23
0
        public void JavaLegacyPOMConversionTest()
        {
            //Arrange
            NewRepositorySerializer RepositorySerializer = new NewRepositorySerializer();
            var businessFlowFile = TestResources.GetTestResourcesFile(@"JavaLegacyToPOMxml" + Path.DirectorySeparatorChar + "Java_Legacy_Actions_BF.Ginger.BusinessFlow.xml");
            var javaPomFile      = TestResources.GetTestResourcesFile(@"JavaLegacyToPOMxml\Java Swing Test App.Ginger.ApplicationPOMModel.xml");

            //Load BF
            mBF = (BusinessFlow)RepositorySerializer.DeserializeFromFile(businessFlowFile);

            mBF.Activities[0].SelectedForConversion = true;

            //Load POM
            ApplicationPOMModel applicationPOM = (ApplicationPOMModel)RepositorySerializer.DeserializeFromFile(javaPomFile);

            mSolutionRepository.AddRepositoryItem(applicationPOM);

            ExecuteActionConversion(true, true, string.Empty, true, applicationPOM.Guid);
            //Assert
            Assert.AreEqual(((ActUIElement)mBF.Activities[1].Acts[1]).ElementLocateBy.ToString(), eLocateBy.POMElement.ToString());
            Assert.AreEqual(((ActUIElement)mBF.Activities[1].Acts[1]).ElementAction.ToString(), ((ActJavaElement)mBF.Activities[0].Acts[1]).ControlAction.ToString());
        }
Example #24
0
        public void ActionClearBackup()
        {
            //Arrange
            BusinessFlow BF = new BusinessFlow();

            BF.Name        = "Businessflow1";
            BF.Description = "Test Clear Backup";
            BF.Activities  = new ObservableList <Activity>();
            Activity a = new Activity();

            a.ActivityName = "Activity 1";
            a.Description  = "Desciption -1";
            BF.Activities.Add(a);
            a.Status = eRunStatus.Passed;

            ActGotoURL g = new ActGotoURL();

            g.Description = "goto URL ";
            g.LocateValue = "ID";
            a.Acts.Add(g);
            string TempFilepath = TestResources.GetTempFile("actionClearBackup.xml");

            //Act
            BF.RepositorySerializer.SaveToFile(BF, TempFilepath);
            a.SaveBackup();
            g.LocateValue = "ID1";
            BF.RepositorySerializer.SaveToFile(BF, TempFilepath);
            a.SaveBackup();
            a.RestoreFromBackup();

            NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
            BusinessFlow            BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), TempFilepath);

            BF2.SaveBackup();//dirty now just indicate if backup exist
            BF2.Description = "aaa";

            // Assert
            Assert.AreEqual(BF2.Activities[0].Acts[0].LocateValue, BF.Activities[0].Acts[0].LocateValue);
        }
Example #25
0
        public void POMWithTargetApplicationKey()
        {
            //Arrange
            ApplicationPlatform AP = new ApplicationPlatform();

            AP.AppName = "App1";
            RepositoryItemKey key = AP.Key;

            ApplicationPOMModel POM = new ApplicationPOMModel();

            POM.Name = "POM1";
            POM.TargetApplicationKey = AP.Key;


            //Act
            string xml = RS.SerializeToString(POM);
            ApplicationPOMModel POM2 = (ApplicationPOMModel)NewRepositorySerializer.DeserializeFromText(xml);

            //Assert
            Assert.AreEqual(POM.Name, POM2.Name);
            Assert.AreEqual(POM2.TargetApplicationKey.Guid, key.Guid);
            Assert.AreEqual(POM2.TargetApplicationKey.ItemName, key.ItemName);
        }
Example #26
0
        public void TestActionLog_CheckActionLogEnableOptionSavedInBFXML()
        {
            //Arrange

            // define action
            ActDummy actDummy = new ActDummy();

            // set all the values in the action
            actDummy.ActionLogConfig = new ActionLogConfig();
            actDummy.ActionLogConfig.ActionLogText = "TestActionLog";
            actDummy.ActionLogConfig.LogRunStatus  = true;
            actDummy.EnableActionLogConfig         = true;

            // define activity
            Activity activity = new Activity();

            activity.ActivityName = "Activity Number 1";

            // define business flow
            BusinessFlow businessFlowWrite = new BusinessFlow();

            businessFlowWrite.Name       = "Business Flow 1";
            businessFlowWrite.Activities = new ObservableList <Activity>();

            activity.Acts.Add(actDummy);
            businessFlowWrite.Activities.Add(activity);

            //Act
            string       txt = businessFlowWrite.RepositorySerializer.SerializeToString(businessFlowWrite);
            BusinessFlow businessFlowRead = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(txt);
            ActDummy     actDummyRead     = (ActDummy)businessFlowRead.Activities[0].Acts[0];

            // Assert
            Assert.AreEqual(actDummyRead.EnableActionLogConfig, actDummy.EnableActionLogConfig);
            Assert.AreEqual(actDummyRead.ActionLogConfig.ActionLogText, actDummy.ActionLogConfig.ActionLogText);
            Assert.AreEqual(actDummyRead.ActionLogConfig.LogRunStatus, actDummy.ActionLogConfig.LogRunStatus);
        }
Example #27
0
        public void BizFlowWithTags()
        {
            //Arrange
            BusinessFlow BF = new BusinessFlow();

            BF.Name        = "Biz flow With Tags";
            BF.Description = "Desc 1";
            BF.Activities  = new ObservableList <Activity>();
            Guid g1 = Guid.NewGuid();
            Guid g2 = Guid.NewGuid();

            BF.Tags.Add(g1);
            BF.Tags.Add(g2);

            Activity a = new Activity();

            a.ActivityName = "Activity number 1";
            a.Description  = "Desc - 1";
            a.Status       = eRunStatus.Passed;
            BF.Activities.Add(a);

            //Act

            string FileName = TestResources.GetTempFile("BFWithTags.xml");

            BF.RepositorySerializer.SaveToFile(BF, FileName);


            // Assert
            NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
            BusinessFlow            BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), FileName);

            Assert.AreEqual(BF2.Name, BF.Name);
            Assert.AreEqual(BF2.Description, BF.Description);
            Assert.AreEqual(BF2.Tags[0], g1);
            Assert.AreEqual(BF2.Tags[1], g2);
        }
Example #28
0
        public static void ClassInitialize(TestContext TC)
        {
            TempRepositoryFolder = TestResources.GetTestTempFolder("Solutions", "SRMultiThreadTestTemp");
            Console.WriteLine("SolutionRepositoryTest folder: " + TempRepositoryFolder);

            Console.WriteLine("===> Creating test solution");
            CreateTestSolution();
            Console.WriteLine("===> test solution created");

            mRepositorySerializer = new NewRepositorySerializer();
            // Init SR
            mSolutionRepository = new SolutionRepository();
            mSolutionRepository.AddItemInfo <MyRepositoryItem>(pattern: "*.Ginger.MyRepositoryItem.xml",   // Need to use for file name
                                                               rootFolder: SolutionRepository.cSolutionRootFolderSign + "MyRepositoryItems",
                                                               containRepositoryItems: true,
                                                               displayName: "My Repository Item",
                                                               PropertyNameForFileName: nameof(MyRepositoryItem.Name)
                                                               );

            NewRepositorySerializer RS = new NewRepositorySerializer();

            NewRepositorySerializer.AddClassesFromAssembly(typeof(MyRepositoryItem).Assembly);
            mSolutionRepository.Open(TempRepositoryFolder);
        }
Example #29
0
        public void ApplicationAPIModelVerifySavedFile()
        {
            // Arrange
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel();

            //AAMS1.GroupName = "Group1";
            AAMS1.Name = "Group1_Operation1";
            SR.AddRepositoryItem(AAMS1);

            //Act
            ObservableList <ApplicationAPIModel> AAMBList = SR.GetAllRepositoryItems <ApplicationAPIModel>();
            ApplicationAPIModel AAMS2 = (ApplicationAPIModel)(from x in AAMBList where x.Guid == AAMS1.Guid select x).FirstOrDefault();

            NewRepositorySerializer RS = new NewRepositorySerializer();
            ApplicationAPIModel     ApplicationAPIModelFromDisk = (ApplicationAPIModel)RS.DeserializeFromFile(AAMS1.FilePath);

            //Assert
            Assert.IsTrue(AAMS2 != null, "New API Model found in AllItems");
            Assert.AreEqual(AAMS1, AAMS2, "Same object is retrieved");

            Assert.AreEqual(AAMS1.Name, ApplicationAPIModelFromDisk.Name, "Name saved to file");
            Assert.AreEqual(AAMS1.Guid, ApplicationAPIModelFromDisk.Guid, "Guid saved to file");
            // TODO: can add more validation
        }
Example #30
0
        public void RunSetConfigSaveLoad()
        {
            //Arrange"
            string TempFilepath = TestResources.GetTempFile("UTRSC1.xml");

            //Act
            RunSetConfig RSC = new RunSetConfig();

            RSC.Name = "UT RSC1";
            GingerRunner ARC1 = new GingerRunner();

            ARC1.Name = " Agent 1";
            BusinessFlowRun BFR = new BusinessFlowRun();

            BFR.BusinessFlowName = "BF1";
            ARC1.BusinessFlowsRunList.Add(BFR);
            RSC.GingerRunners.Add(ARC1);

            RSC.RepositorySerializer.SaveToFile(RSC, TempFilepath);

            //Assert
            NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
            RunSetConfig            RSC2 = (RunSetConfig)newRepositorySerializer.DeserializeFromFile(typeof(RunSetConfig), TempFilepath);
        }