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); }
public static UserProfile LoadUserProfile() { if (General.isDesignMode()) { return(null); } string InstallationConfigurationPath = System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("Ginger.exe", "Ginger.InstallationConfiguration.Json"); DateTime InstallationDT = File.GetLastWriteTime(InstallationConfigurationPath); string UserConfigJsonString = string.Empty; JObject UserConfigJsonObj = null; Dictionary <string, string> UserConfigdictObj = null; if (System.IO.File.Exists(InstallationConfigurationPath)) { UserConfigJsonString = System.IO.File.ReadAllText(InstallationConfigurationPath); UserConfigJsonObj = JObject.Parse(UserConfigJsonString); UserConfigdictObj = UserConfigJsonObj.ToObject <Dictionary <string, string> >(); } if (File.Exists(UserProfileFilePath)) { try { DateTime UserProfileDT = File.GetLastWriteTime(UserProfileFilePath); Reporter.ToLog(eAppReporterLogLevel.INFO, string.Format("Loading existing User Profile at '{0}'", UserProfileFilePath)); string userProfileTxt = File.ReadAllText(UserProfileFilePath); UserProfile up = (UserProfile)NewRepositorySerializer.DeserializeFromText(userProfileTxt); up.FilePath = UserProfileFilePath; if (DateTime.Compare(UserProfileDT, InstallationDT) < 0) { if (UserConfigdictObj != null) { up.AddUserConfigProperties(UserConfigdictObj); } } return(up); } catch (Exception ex) { Reporter.ToLog(eAppReporterLogLevel.ERROR, string.Format("Failed to load the existing User Profile at '{0}'", UserProfileFilePath), ex); } } Reporter.ToLog(eAppReporterLogLevel.INFO, "Creating new User Profile"); UserProfile up2 = new UserProfile(); up2.LoadDefaults(); if (UserConfigdictObj != null) { up2.AddUserConfigProperties(UserConfigdictObj); } return(up2); }
public void VerifySerialzedAttrDefaultValue() { //Arrange BusinessFlow BF = new BusinessFlow("BF1"); //Act string xml = RS.SerializeToString(BF); BusinessFlow BF2 = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(xml); //Assert Assert.AreEqual(BF.Source, BusinessFlow.eSource.Ginger); Assert.AreEqual(BF.Active, BF2.Active); }
public static Solution LoadSolution(string solutionFileName, bool startDirtyTracking = true) { string txt = File.ReadAllText(solutionFileName); Solution solution = (Solution)NewRepositorySerializer.DeserializeFromText(txt); solution.FilePath = solutionFileName; solution.Folder = Path.GetDirectoryName(solutionFileName); if (startDirtyTracking) { solution.StartDirtyTracking(); } return(solution); }
public void BFToStringAndBack() { //Arrange BusinessFlow BF = new BusinessFlow("BF1"); //Act string xml = RS.SerializeToString(BF); BusinessFlow BF2 = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(xml); //Assert Assert.AreEqual(BF.Name, BF2.Name); }
public void BusinessFlowDeserializationTest() { //Arrange string sFileName = TestResources.GetTestResourcesFile(@"Converter" + Path.DirectorySeparatorChar + "IPDLSAM.Ginger.BusinessFlow.xml"); string txt = File.ReadAllText(sFileName); //Act BusinessFlow BF = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(txt); //Assert //TODO: add more asserts Assert.AreEqual(14, BF.Activities.Count, "BF has 14 activities"); }
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); }
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); }
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); } } }
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); }
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); }
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); }
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); }
public void VerifyRepositoryItemHeaderSaveLoad() { //Arrange BusinessFlow BF = new BusinessFlow("BF123"); //Act string xml = RS.SerializeToString(BF); BusinessFlow BF2 = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(xml); //Assert Assert.AreNotEqual(BF, BF2); // need to be 2 dfferent ref, but with same data Assert.AreEqual(BF.Name, BF2.Name); Assert.AreEqual(BF.RepositoryItemHeader.CreatedBy, BF2.RepositoryItemHeader.CreatedBy); Assert.AreEqual(BF.RepositoryItemHeader.Created, BF2.RepositoryItemHeader.Created); Assert.AreEqual(BF.RepositoryItemHeader.Version, BF2.RepositoryItemHeader.Version); Assert.AreEqual(BF.RepositoryItemHeader.LastUpdate, BF2.RepositoryItemHeader.LastUpdate); Assert.AreEqual(BF.RepositoryItemHeader.LastUpdateBy, BF2.RepositoryItemHeader.LastUpdateBy); Assert.AreEqual(BF.RepositoryItemHeader.GingerVersion, BF2.RepositoryItemHeader.GingerVersion); Assert.AreEqual(BF.RepositoryItemHeader.ItemType, BF2.RepositoryItemHeader.ItemType); Assert.AreEqual(BF.RepositoryItemHeader.ItemGuid, BF2.RepositoryItemHeader.ItemGuid); Assert.AreEqual(BF.Guid, BF2.Guid); Assert.AreEqual(BF.Guid, BF2.RepositoryItemHeader.ItemGuid); }
public void ApiModelTagItemKey() { //Arrange ApplicationAPIModel API = new ApplicationAPIModel(); RepositoryItemKey Tag1 = new RepositoryItemKey(); Tag1.ItemName = "Tag1"; Tag1.Guid = Guid.NewGuid(); API.TagsKeys.Add(Tag1); RepositoryItemKey Tag2 = new RepositoryItemKey(); Tag2.ItemName = "Tag2"; Tag2.Guid = Guid.NewGuid(); API.TagsKeys.Add(Tag2); //Act string xml = RS.SerializeToString(API); ApplicationAPIModel API2 = (ApplicationAPIModel)NewRepositorySerializer.DeserializeFromText(xml); //Assert Assert.AreEqual(API.TagsKeys[0].Key, API2.TagsKeys[0].Key); Assert.AreEqual(API.TagsKeys[1].Key, API2.TagsKeys[1].Key); }
public static UserProfile LoadUserProfile() { if (General.isDesignMode()) { return(null); } string InstallationConfigurationPath = Assembly.GetExecutingAssembly().Location.Replace(Path.GetFileName(Assembly.GetExecutingAssembly().Location), "Ginger.InstallationConfiguration.Json"); string UserConfigJsonString = string.Empty; JObject UserConfigJsonObj = null; Dictionary <string, string> UserConfigdictObj = null; if (System.IO.File.Exists(InstallationConfigurationPath)) { UserConfigJsonString = System.IO.File.ReadAllText(InstallationConfigurationPath); UserConfigJsonObj = JObject.Parse(UserConfigJsonString); UserConfigdictObj = UserConfigJsonObj.ToObject <Dictionary <string, string> >(); } if (File.Exists(UserProfileFilePath)) { try { DateTime UserProfileDT = File.GetLastWriteTime(UserProfileFilePath); Reporter.ToLog(eLogLevel.INFO, string.Format("Loading existing User Profile at '{0}'", UserProfileFilePath)); string userProfileTxt = File.ReadAllText(UserProfileFilePath); UserProfile up = (UserProfile)NewRepositorySerializer.DeserializeFromText(userProfileTxt); up.FilePath = UserProfileFilePath; if (UserConfigdictObj != null && DateTime.Compare(UserProfileDT, File.GetLastWriteTime(InstallationConfigurationPath)) < 0) { up.AddUserConfigProperties(UserConfigdictObj); } return(up); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to load the existing User Profile at '{0}'", UserProfileFilePath), ex); try { //create backup to the user profile so user won't lose all of it configs in case he went back to old Ginger version //TODO- allow recover from newer User Profile version in code instead creating new user profile Reporter.ToLog(eLogLevel.INFO, "Creating backup copy for the User Profile file"); File.Copy(UserProfileFilePath, UserProfileFilePath.Replace("Ginger.UserProfile.xml", "Ginger.UserProfile-Backup.xml"), true); } catch (Exception ex2) { Reporter.ToLog(eLogLevel.ERROR, "Failed to create backup copy for the User Profile file", ex2); } } } Reporter.ToLog(eLogLevel.INFO, "Creating new User Profile"); UserProfile up2 = new UserProfile(); up2.LoadDefaults(); if (UserConfigdictObj != null) { up2.AddUserConfigProperties(UserConfigdictObj); } return(up2); }
private void Upgrade(object sender, RoutedEventArgs e) { try { xProcessingImage.Visibility = Visibility.Visible; GingerCore.General.DoEvents(); NewRepositorySerializer newSerilizer = new NewRepositorySerializer(); mFailedFiles = new List <string>(); string backupFolderPath = BackupFolderTextBox.Text; //make sure back direcroty exist if not create if (!Directory.Exists(backupFolderPath)) { MakeSurePathExistforBakFile(backupFolderPath + @"\"); } // now do the upgrade file by file foreach (string filePathToConvert in mFilesToShow) { string filePath = filePathToConvert; //remove info extention if (filePath.Contains("-->")) { filePath = filePath.Remove(filePath.IndexOf("-->")); } //do upgrade try { //first copy to backup folder string BakFile = filePath.Replace(mSolutionFolder, BackupFolderTextBox.Text + @"\"); MakeSurePathExistforBakFile(BakFile); System.IO.File.Copy(filePath, BakFile, true); //make sure backup was created if (File.Exists(BakFile) == true) { //Do Upgrade by unserilize and serlize the item using new serilizer //unserilize string itemXML = File.ReadAllText(filePath); RepositoryItemBase itemObject = (RepositoryItemBase)NewRepositorySerializer.DeserializeFromText(itemXML); itemObject.FilePath = filePath; //serlize 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); } } if (mFailedFiles.Count == 0) { Reporter.ToUser(eUserMsgKeys.StaticInfoMessage, "Upgrade ended successfully."); _pageGenericWin.Close(); } else { Reporter.ToUser(eUserMsgKeys.StaticWarnMessage, "Upgrade failed for some of the files."); mViewMode = SolutionUpgradePageViewMode.FailedUpgradeSolution; SetControls(); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to upgrade the solution files", ex); Reporter.ToUser(eUserMsgKeys.StaticErrorMessage, "Error occurred during upgrade, details: " + ex.Message); _pageGenericWin.Close(); } finally { xProcessingImage.Visibility = Visibility.Collapsed; } }