public void TestMethod6()
        {
            string                 file        = File.ReadAllText(@"TestFiles\Test1.html");
            const string           KEY         = "button";
            const string           NAME        = "Dish";
            const string           SECOND_NAME = "CompleteDish";
            const string           CLASS_NAME  = "DishCreator";
            ComponentsContainer    basicComponentsContainer = ComponentsContainer.Instance;
            ComponentsFactory      factory = new ComponentsFactory(basicComponentsContainer, basicComponentsContainer, basicComponentsContainer, basicComponentsContainer);
            Mock <IComponentAddin> addin   = new Mock <IComponentAddin>();

            addin.Setup(add => add.AddinKey).Returns(KEY);
            addin.Setup(add => add.GenerateHelpers(CLASS_NAME, NAME, It.IsAny <IPropertyGenerator>())).Returns(new[] { $"{CLASS_NAME} With{NAME}(string {NAME.ToLower()}){{}}" });
            addin.Setup(add => add.GenerateHelpers(CLASS_NAME, SECOND_NAME, It.IsAny <IPropertyGenerator>())).Returns(new[] { $"{CLASS_NAME} {SECOND_NAME}(){{}}" });
            addin.Setup(add => add.Type).Returns(Consts.WEB_ELEMENT_CLASS_NAME);

            basicComponentsContainer.AddAddin(addin.Object);

            var files = factory.CreateCsOutput(file);

            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE));
            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE));
            foreach (ComponentGeneratorOutput innerFile in files)
            {
                File.WriteAllText(innerFile.CsFilePath, innerFile.Body);
            }
        }
        public virtual ComponentGeneratorOutput GenerateComponentClass(string selector, ElementSelectorData[] elements)
        {
            string className = SelectorUtils.GetClassOrPropNameFromSelector(selector);

            if (InheritFromBaseClass)
            {
                _classBuilder.AddInheritance(Consts.DRIVER_CONTAINER_CLASS_NAME);
            }
            string body = _classBuilder
                          .AddUsings(GetUsings(elements))
                          .AddCtor(CreateCtor(className))
                          .SetClassName(className)
                          .SetNamesapce(NamespaceName)
                          .AddUsings(GetUsings(elements))
                          .AddProperties(GetProperties(elements))
                          .AddMethods(GetHelpers(className, elements))
                          .AddFields(GetFields())
                          .Build();

            return(new ComponentGeneratorOutput
            {
                Body = body,
                CsFilePath = NamespaceFileConverter.ConvertNamespaceToFilePath(NamespaceName, className)
            });
        }
        private static ComponentGeneratorOutput CreateBasicClass(string body, string className)
        {
            string fileName = NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.BASE_NAMESPACE, $"{className}.cs");

            return(new ComponentGeneratorOutput
            {
                Body = body,
                CsFilePath = fileName
            });
        }
 private static void CreateFiles(string distDirectory, IEnumerable <ComponentGeneratorOutput> results)
 {
     Directory.CreateDirectory(distDirectory);
     Directory.CreateDirectory(distDirectory + "\\" + NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE));
     Directory.CreateDirectory(distDirectory + "\\" + NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE));
     Directory.CreateDirectory(distDirectory + "\\" + NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.BASE_NAMESPACE));
     foreach (ComponentGeneratorOutput result in results)
     {
         File.WriteAllText(distDirectory + "\\" + result.CsFilePath, result.Body);
     }
 }
        public void TestMethod14()
        {
            string file = File.ReadAllText(@"TestFiles\Test1.html");

            BuiltInComponentsInserter.InsertBuiltInComponents();
            var basicComponentsContainer = ComponentsContainer.Instance;
            ComponentsFactory factory    = new ComponentsFactory(basicComponentsContainer, basicComponentsContainer, basicComponentsContainer, basicComponentsContainer);
            var files = factory.CreateCsOutput(file);

            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE));
            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE));
            foreach (var innerFile in files)
            {
                File.WriteAllText(innerFile.CsFilePath, innerFile.Body);
            }
        }
        public void TestMethod7()
        {
            string                 file  = File.ReadAllText(@"TestFiles\Test1.html");
            const string           KEY   = "label";
            Mock <IComponentAddin> addin = new Mock <IComponentAddin>();

            addin.Setup(add => add.AddinKey).Returns(KEY);
            addin.Setup(add => add.Type).Returns("string");
            ComponentsContainer basicComponentsContainer = ComponentsContainer.Instance;

            basicComponentsContainer.AddAddin(new LabelAddin());
            basicComponentsContainer.AddAddin(new InputAddin());
            ComponentsFactory factory = new ComponentsFactory(basicComponentsContainer, basicComponentsContainer, basicComponentsContainer, basicComponentsContainer);
            var files = factory.CreateCsOutput(file);

            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE));
            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE));
            foreach (var innerFile in files)
            {
                File.WriteAllText(innerFile.CsFilePath, innerFile.Body);
            }
        }
        public void TestMethod1()
        {
            const string           KEY        = "ccc";
            const string           NAME       = "bbb";
            const string           CLASS_NAME = "DishCreator";
            const string           SELECTOR   = "auto-page-" + CLASS_NAME;
            ComponentsContainer    basicComponentsContainer = ComponentsContainer.Instance;
            PageGenerator          generator = new PageGenerator(new BasicClassBuilder(), new DriverFindElementPropertyGenerator("Driver"), basicComponentsContainer, Consts.PAGES_NAMESPACE);
            Mock <IComponentAddin> addin     = new Mock <IComponentAddin>();

            addin.Setup(add => add.AddinKey).Returns(KEY);
            addin.Setup(add => add.GenerateHelpers(CLASS_NAME, NAME, generator.PropertyGenerator)).Returns(new[] { "void Main(){}", "public void Main2(){}" });
            addin.Setup(add => add.Type).Returns("string");

            basicComponentsContainer.AddAddin(addin.Object);

            var classStr = generator.GenerateComponentClass(SELECTOR, new[] { new ElementSelectorData {
                                                                                  FullSelector = "aaa", Name = NAME, Type = KEY, AutomationAttributes = new string[0]
                                                                              } });

            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE));
            Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE));
            File.WriteAllText(classStr.CsFilePath, classStr.Body);
        }