示例#1
0
 protected void Execute(ProjectFileWriter project, string type, string fileFormat, string className, string template)
 {
     var className2 = Options.Do.Conventions.Pluralize(className);
     var file = fileFormat.AsFormat(className, className2);
     if (!project.ExistsFile(file))
         project.AddNewFile(file, type, GetTemplate(template, className).ToString());
 }
示例#2
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Creating project...");

            string projectName      = args.Any() ? args[0] : "buildify-ui-template";
            string projectPath      = Environment.CurrentDirectory;
            string innerProjectPath = $"{projectPath}{Path.DirectorySeparatorChar}{projectName}";

            var fileWriter    = new ProjectFileWriter();
            var folderWriter  = new ProjectFolderWriter();
            var fileFactory   = new ProjectFileFactory();
            var folderFactory = new ProjectFolderFactory(projectName);

            var composer = new ProjectComposer(
                fileFactory,
                folderFactory,
                fileWriter,
                folderWriter,
                projectPath,
                projectName);

            await composer.Compose();

            Console.WriteLine($"Project created at: {innerProjectPath}");
        }
示例#3
0
        public void TestInitialize()
        {
            DeleteProjectFileIfExists();

            projectFilePath = TestContext.TestDir + Path.DirectorySeparatorChar + PROJECT_NAME + OpcMockConstants.FileExtensionProject;

            projectFileWriter = new ProjectFileWriter(new OpcMockProject(PROJECT_NAME), TestContext.TestDir);
        }
        public void CanAddCompileFileToProjectWithoutWriteChanges()
        {
            using (var writer = new ProjectFileWriter("test/test.csproj"))
                writer.AddNewCompile("asd/qwe/simsim.txt", "olá");

            StringAssert.Contains(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj"));
            File.ReadAllText("test/asd/qwe/simsim.txt").Should().Be("olá");
        }
        public void CanAddCompileBinaryFileToProject()
        {
            var writer = new ProjectFileWriter("test/test.csproj");
            writer.AddNewCompile("asd/qwe/simsim.txt", new byte[] { 1, 2, 3 });
            writer.WriteChanges();

            StringAssert.Contains(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj"));
            File.ReadAllBytes("test/asd/qwe/simsim.txt").Should().Have.SameSequenceAs<byte>(1, 2, 3);
        }
示例#6
0
        protected void Execute(ProjectFileWriter project, string type, string fileFormat, string className, string template)
        {
            var className2 = Options.Do.Conventions.Pluralize(className);
            var file       = fileFormat.AsFormatFor(className, className2);

            if (!project.ExistsFile(file))
            {
                project.AddNewFile(file, type, GetTemplate(template, className).ToString());
            }
        }
        public void CanAddAlreadyExistingFileWontWriteChanges()
        {
            var writer = new ProjectFileWriter("test/test.csproj");
            writer.AddNewCompile("asd/qwe/simsim.txt", "olá");
            writer.WriteChanges();

            using (new FileInfo(writer.ProjectPath).Open(FileMode.Open, FileAccess.ReadWrite))
            {
                writer.AddNewCompile("asd/qwe/simsim.txt", "olá");
                writer.WriteChanges();
            }
        }
        public void AddCompileFileToProjectThenRemoveItWontDeleteTheFile()
        {
            var writer = new ProjectFileWriter("test/test.csproj");
            writer.AddNewCompile("asd/qwe/simsim.txt", "olá");
            writer.WriteChanges();

            writer.RemoveFile("asd/qwe/simsim.txt");
            writer.WriteChanges();

            StringAssert.DoesNotContain(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj"));
            File.ReadAllText("test/asd/qwe/simsim.txt").Should().Be("olá");
        }
示例#9
0
 public ProjectComposer(
     ProjectFileFactory fileFactory,
     ProjectFolderFactory folderFactory,
     ProjectFileWriter fileWriter,
     ProjectFolderWriter folderWriter,
     string projectPath,
     string projectName)
 {
     this.fileFactory   = fileFactory;
     this.folderFactory = folderFactory;
     this.fileWriter    = fileWriter;
     this.folderWriter  = folderWriter;
     this.projectPath   = projectPath;
     this.projectName   = projectName;
 }
示例#10
0
        public void SaveShould_Write_Protocol_Segment()
        {
            OpcMockProject projectWithOneProtocol = new OpcMockProject(PROJECT_NAME);
            string         firstProtocolName      = "firstProtocol";

            projectWithOneProtocol.AddProtocol(new OpcMockProtocol(firstProtocolName));

            projectFileWriter = new ProjectFileWriter(projectWithOneProtocol, TestContext.TestDir);

            XElement fileContentStartXml = new XElement("project",
                                                        new XElement("project_name", PROJECT_NAME),
                                                        new XElement("protocol_list",
                                                                     new XElement("protocol", firstProtocolName)));

            SaveContentToFileAndCheckResult(fileContentStartXml.ToString());
        }
示例#11
0
        /// <summary>
        /// 各種ファイル出力処理
        /// </summary>
        public void doExport()
        {
            // 成果物ファイル達を出力
            writeArtifactFiles();

            // Projectファイルを出力
            ProjectFileWriter.outputProjectFile(outputDir, allArtifacts.targetProject);

            // 要素一覧CSVファイル、属性・操作一覧CSVファイルの出力
            AllElementsCsvWriter csvWriter = new AllElementsCsvWriter(outputDir);

            csvWriter.outputElementsCsv(this.allArtifacts);
            csvWriter.outputMthAttrCsv(this.allArtifacts);

            // ふるまいファイルの出力
            // AllBehaviorsWriter bhvWriter = new AllBehaviorsWriter(outputDir);
            // bhvWriter.outputBehaviorsText(this.allArtifacts);
        }
示例#12
0
        public static List<ITableTemplate> MakeTemplateList(ProjectFileWriter model, ProjectFileWriter server)
        {
            var list = new List<ITableTemplate>();
            list.Add(new TableTemplate(Templates.Entity)
                .Target(model, "Domain/Generated/{0}.cs"));

            list.Add(new TableTemplate(Templates.Mapping)
                .Target(model, "Domain/Generated/{0}.hbm.xml")
                .As(ProjectWriter.EmbeddedResource));

            list.Add(new TableTemplate(Templates.IService)
                .Target(model, "Services/I{0}Service.cs")
                .SetOverwrite(false));

            list.Add(new TableTemplate(Templates.Validator)
                .Target(model, "Validators/{0}Validator.cs")
                .SetOverwrite(false));

            list.Add(new TableTemplate(Templates.Service)
               .Target(server, "Services/{0}Service.cs")
               .SetOverwrite(false));
            return list;
        }
示例#13
0
        public static List <ITableTemplate> MakeTemplateList(ProjectFileWriter model, ProjectFileWriter server)
        {
            var list = new List <ITableTemplate>();

            list.Add(new TableTemplate(Templates.Entity)
                     .Target(model, "Domain/Generated/{0}.cs"));

            list.Add(new TableTemplate(Templates.Mapping)
                     .Target(model, "Domain/Generated/{0}.hbm.xml")
                     .As(ProjectWriter.EmbeddedResource));

            list.Add(new TableTemplate(Templates.IService)
                     .Target(model, "Services/I{0}Service.cs")
                     .SetOverwrite(false));

            list.Add(new TableTemplate(Templates.Validator)
                     .Target(model, "Validators/{0}Validator.cs")
                     .SetOverwrite(false));

            list.Add(new TableTemplate(Templates.Service)
                     .Target(server, "Services/{0}Service.cs")
                     .SetOverwrite(false));
            return(list);
        }
        public void CanCheckIfFileExists()
        {
            var writer = new ProjectFileWriter("test/test.csproj");

            Assert.False(writer.ExistsFile("asd/qwe/simsim.txt"));
            writer.AddNewCompile("asd/qwe/simsim.txt", "olá");

            Assert.True(writer.ExistsFile("asd/qwe/simsim.txt"));
            writer.WriteChanges();
        }
 public void CannotOpenFileUsingPatternOnlyWhenItDoesntExist()
 {
     var writer = new ProjectFileWriter("test/te?.csproj");
     writer.ProjectPath.Should().Be(Path.GetFullPath("test/test.csproj"));
 }
        public void CanAddCrazyFileToProject()
        {
            var writer = new ProjectFileWriter("test/test.csproj");
            writer.AddNewFile("asd/qwe/simsim.txt", "ASDASD", "olá");
            writer.WriteChanges();

            StringAssert.Contains(@"<ASDASD Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj"));
            File.ReadAllText("test/asd/qwe/simsim.txt").Should().Be("olá");
        }
 public void CanOpenFileUsingPatternOnly()
 {
     var writer = new ProjectFileWriter("test/te??.csproj");
     writer.ProjectPath.Should().Be(Path.GetFullPath("test/test.csproj"));
 }
 public void CanResolveFullPathInsideAProject()
 {
     var writer = new ProjectFileWriter("test/test.csproj");
     var path = writer.GetFullPath("asd/qwe/simsim.txt");
     StringAssert.EndsWith(@"test\asd\qwe\simsim.txt", path);
 }
 public void CanOpenFileUsingPatternWithNoDirectory()
 {
     Environment.CurrentDirectory = Environment.CurrentDirectory + "/test";
     var writer = new ProjectFileWriter("te??.csproj");
     writer.ProjectPath.Should().Be(Path.GetFullPath("test.csproj"));
 }
示例#20
0
 public ITableTemplate Target(ProjectFileWriter project, string file)
 {
     Project = project;
     FileTemplate = file;
     return this;
 }
        public void CanAddCompileFileToProjectWorkEvenIfWeChangeDir()
        {
            var writer = new ProjectFileWriter("test/test.csproj");

            Environment.CurrentDirectory = dir.ToString();
            writer.AddNewCompile("asd/qwe/simsim.txt", "olá");
            writer.WriteChanges();

            StringAssert.Contains(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test.csproj"));
            File.ReadAllText("asd/qwe/simsim.txt").Should().Be("olá");
        }