public void FilePathGenerator_GenerateFilePath_ShouldReturnCorrectPath(
            string projectDir,
            string relativeOutputDir,
            string featureFile,
            string generatedCodeBehindName,
            string expected)
        {
            // ARRANGE
            var filePathGenerator = new FilePathGenerator();

            // ACT
            string actual = filePathGenerator.GenerateFilePath(projectDir, relativeOutputDir, featureFile, generatedCodeBehindName);

            // ASSERT
            actual.Should().Be(expected);
        }
Ejemplo n.º 2
0
        public IEnumerable <string> GenerateFilesForProject(
            IReadOnlyCollection <string> tableFiles,
            string projectFolder,
            string outputPath)
        {
            var codeBehindWriter = new CodeBehindWriter(null);

            if (tableFiles == null)
            {
                yield break;
            }

            foreach (var tableFile in tableFiles)
            {
                string tableFileItemSpec = tableFile;
                var    generatorResult   = _tableCodeBehindGenerator.GenerateCodeBehindFile(tableFileItemSpec);

                if (!generatorResult.Success)
                {
                    foreach (var error in generatorResult.Errors)
                    {
                        Log.LogError(
                            null,
                            null,
                            null,
                            tableFile,
                            error.Line,
                            error.LinePosition,
                            0,
                            0,
                            error.Message);
                    }

                    continue;
                }

                string targetFilePath = _filePathGenerator.GenerateFilePath(
                    projectFolder,
                    outputPath,
                    tableFile,
                    generatorResult.Filename);

                string resultedFile = codeBehindWriter.WriteCodeBehindFile(targetFilePath, tableFile, generatorResult);

                yield return(FileSystemHelper.GetRelativePath(resultedFile, projectFolder));
            }
        }
        public void FilePathGenerator_GenerateFilePath_ShouldReturnCorrectPath_Linux(
            string projectDir,
            string relativeOutputDir,
            string featureFile,
            string generatedCodeBehindName,
            string expected)
        {
            Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX));

            // ARRANGE
            var filePathGenerator = new FilePathGenerator();

            // ACT
            string actual = filePathGenerator.GenerateFilePath(projectDir, relativeOutputDir, featureFile, generatedCodeBehindName);

            // ASSERT
            actual.Should().Be(expected);
        }