public void TestXMLReadWriteWithPoco() { var solution = new TranslatorSolution(); solution.SetName("My TestSolution"); solution.SetComment("This is test solution for testing purposes only"); var project = new Project(); project.SetSourceFile(new FileReference(@"C:\TEMP\Source.resx", "RESX", "This is a test source file comment")); project.AddTargetFile(new FileReference(@"C:\TEMP\Source_DE_DE.resx", "RESX", "This is a test target file comment")); solution.AddProject(project); // Persist content into string var modelExtension = new PersistSolutionModelInXML(); var XML = modelExtension.GetXMLString(solution); var loadedSolution = new PersistSolutionModelInXML(); TranslatorSolutionLib.Models.TranslatorSolution sol = new TranslatorSolutionLib.Models.TranslatorSolution(); // Retrieve content back into object values and check if this worked as expected Assert.AreEqual(loadedSolution.SetXMLString(XML, sol), true); }
public void TestXMLInternediateReadWithPoco() { var solution = new TranslatorSolution(); solution.SetName("My TestSolution"); solution.SetComment("This is test solution for testing purposes only"); var project = new Project(); project.SetSourceFile(new FileReference(@"C:\TEMP\Source.resx", "RESX", "This is a test source file comment")); project.AddTargetFile(new FileReference(@"C:\TEMP\Source_DE_DE.resx", "RESX", "This is a test target file comment")); solution.AddProject(project); // Persist content into string var modelExtension = new PersistSolutionModelInXML(); var XML = modelExtension.GetXMLString(solution); var XMLStringSource = new ModelToXML(); var XML1 = XMLStringSource.ToString(solution); Assert.AreEqual(string.Compare(XML, XML1), 0); }
/// <summary> /// Adds a new project entry based on the given model. /// </summary> /// <param name="model"></param> public void AddProject(Project model) { var fr = new ProjectViewModel(model, this); var item = Children.SingleOrDefault(p => string.Compare(p.Path, fr.Path, true) == 0); if (item == null) { Children.Add(fr); // Add viewmodel and model into children collection mSolutionModel.AddProject(model); IsDirty = true; } else { var project = item as ProjectViewModel; if (project != null) { if (project.SourceFile != null) { // Just adjust non key values if this item is already there project.SourceFile.Comment = fr.SourceFile.Comment; project.SourceFile.Type = fr.SourceFile.Type; IsDirty = true; } } } }
/// <summary> /// Converts the given parameters into a solution model and returns it. /// </summary> /// <param name="solutionPathName"></param> /// <param name="newSolutionName"></param> /// <param name="TargetFilesCollection"></param> /// <returns></returns> public static TranslatorSolution ConvertToSolutionModel(string solutionPathName, string newSolutionName, string newSourceFilePathName, string newCommment, IList <FileReferenceViewModel> TargetFilesCollection) { // Build solution model var solution = new TranslatorSolution(newSolutionName); var project = new Project(); project.SetSourceFile(new FileReference(newSourceFilePathName, UpdateNewSolutionTargetFilesViewModel.mDefaultType, newCommment)); foreach (var item in TargetFilesCollection) { project.AddTargetFile(item.GetModel()); } solution.AddProject(project); return(solution); }
public void TestXMLReadWriteIntermediateWithPoco() { var solution = new TranslatorSolution(); solution.SetName("My TestSolution"); solution.SetComment("This is test solution for testing purposes only"); var project = new Project(); project.SetSourceFile(new FileReference(@"C:\TEMP\Source.resx", "RESX", "This is a test source file comment")); project.AddTargetFile(new FileReference(@"C:\TEMP\Source_DE_DE.resx", "RESX", "This is a test target file comment")); solution.AddProject(project); // Persist content into string var XMLStringSource = new ModelToXML(); var XML = XMLStringSource.ToString(solution); var XMLSource = new XMLToModel(); TranslatorSolutionLib.Models.TranslatorSolution sol = new TranslatorSolutionLib.Models.TranslatorSolution(); // Retrieve content back into object values and check if this worked as expected Assert.AreEqual(XMLSource.SetXMLString(sol, XML), true); // Now back to XML and compare with first XML representation var XMLStringSource1 = new ModelToXML(); var XML1 = XMLStringSource1.ToString(sol); Assert.AreEqual(string.Compare(XML, XML1, false), 0); }