internal void GenerateSourceCodeForPageObject() { var definitions = Presenters.PageObjectDefinitionPresenter.GetWebElementDefinitionFromTree(); var generator = new CSharpPageObjectGenerator(); string selectedTemalateName = view.GetSelectedTemplateFile(); if (string.IsNullOrWhiteSpace(selectedTemalateName)) { view.WarnTemplateNeedsToBeSelected(); return; } var fullTemplatePath = Path.Combine(GetDefaultCodeTemplateDirectory(), selectedTemalateName + codeTemplateFileExtension); string[] code; try { code = generator.Generate(definitions, fullTemplatePath); } catch (Exception e) { MyLog.Exception(e); throw; } view.DisplayGeneratedCode(code); }
public void CSharpPageObjectGenerator_Generate(string templateFileName) { CSharpPageObjectGenerator engine = new CSharpPageObjectGenerator(); string templatesFolder = Path.Combine(Helper.AssemblyDirectory(), "CodeTemplates"); string fileName = Path.Combine(templatesFolder, templateFileName); SwdPageObject pageObject = new SwdPageObject(); string expectedName = "ExpectedName123456"; pageObject.PageObjectName = expectedName; string[] output = engine.Generate(pageObject, fileName); string actual = string.Join("", output); actual.Should().Contain(expectedName); Console.WriteLine(actual); }