internal void LoadPageObject(string pageObjectFileName) { string pageObjectFile = pageObjectFileName + PoxFileExtension; string targetFullPath = Path.Combine(GetDefaultPageObjectsDirectory(), pageObjectFile); WebSpyPageObject pageObject = null; try { pageObject = LoadPageObjectFromFile(targetFullPath); } catch (Exception e) { MyLog.Exception(e); view.NotifyOnLoadError(e.Message, targetFullPath); return; } view.ClearPageObjectTree(); foreach (var def in pageObject.Items) { UpdatePageDefinition(def, forceAddNew: true); } IsDirty = false; lastSavedFilePath = targetFullPath; UpdateControlsState(); RaisePageObjectTreeChanged(); }
private WebSpyPageObject LoadPageObjectFromFile(string pageObjectFileName) { WebSpyPageObject definitions = null; using (FileStream stream = File.OpenRead(pageObjectFileName)) { var serializer = new XmlSerializer(typeof(WebSpyPageObject)); definitions = (WebSpyPageObject)serializer.Deserialize(stream); } return(definitions); }
public void CSharpPageObjectGenerator_Generate(string templateFileName) { CSharpPageObjectGenerator engine = new CSharpPageObjectGenerator(); string templatesFolder = Path.Combine(Helper.AssemblyDirectory(), "CodeTemplates"); string fileName = Path.Combine(templatesFolder, templateFileName); WebSpyPageObject pageObject = new WebSpyPageObject(); string expectedName = "ExpectedName123456"; pageObject.PageObjectName = expectedName; string[] output = engine.Generate(pageObject, fileName); string actual = string.Join("", output); actual.Should().Contain(expectedName); Console.WriteLine(actual); }
public string[] Generate(WebSpyPageObject pageObject, string fullTemplatePath) { var template = File.ReadAllText(fullTemplatePath); object model = new TemplateViewModel() { PageObject = pageObject }; string result = "not parsed"; try { result = Razor.Parse(template, model); } catch { throw; } return(Utils.SplitSingleLineToMultyLine(result)); }