private List <AltinnCoreFile> MapFilesToAltinnCoreFiles(IEnumerable <string> schemaFiles) { var altinnCoreSchemaFiles = new List <AltinnCoreFile>(); foreach (string file in schemaFiles) { altinnCoreSchemaFiles.Add(AltinnCoreFile.CreateFromPath(file, RepositoryDirectory)); } return(altinnCoreSchemaFiles); }
public void CreateFromPath_ValidPath_ShouldCreateInstanse() { var org = "ttd"; var repository = "ttd-datamodels"; var userName = "******"; var repositoryRootPath = TestDataHelper.GetTestDataRepositoryDirectory(org, repository, userName); var fileName = "0678.xsd"; var directory = $"{repositoryRootPath}\\App\\models"; var filePath = $"{directory}\\0678.xsd"; var altinnCoreFile = AltinnCoreFile.CreateFromPath(filePath, repositoryRootPath); Assert.Equal(fileName, altinnCoreFile.FileName); Assert.Equal(@".xsd", altinnCoreFile.FileType); Assert.Equal(@"/App/models/0678.xsd", altinnCoreFile.RepositoryRelativeUrl); Assert.Equal(directory, altinnCoreFile.Directory); Assert.Equal(filePath, altinnCoreFile.FilePath); altinnCoreFile.LastChanged.Should().BeOnOrBefore(DateTime.Now); }
private List <AltinnCoreFile> GetImplementationFiles() { List <AltinnCoreFile> coreFiles = new List <AltinnCoreFile>(); string path = repoPath; string[] files = Directory.GetFiles(path + "/Implementation"); foreach (string file in files) { AltinnCoreFile corefile = new AltinnCoreFile { FilePath = file, FileName = Path.GetFileName(file), LastChanged = File.GetLastWriteTime(file), }; coreFiles.Add(corefile); } string[] modelFiles = null; if (Directory.Exists(path + "/Model")) { modelFiles = Directory.GetFiles(path + "/Model"); foreach (string file in modelFiles) { AltinnCoreFile corefile = new AltinnCoreFile { FilePath = file, FileName = Path.GetFileName(file), LastChanged = File.GetLastWriteTime(file), }; coreFiles.Add(corefile); } } return(coreFiles); }
/// <summary> /// Gets a <see cref="AltinnCoreFile"/> representation of a file. This does not load any /// file contents but i do ensure the file exists ang gives some easy handles to file location and url /// </summary> /// <param name="realtiveFilepath">The relative path to the file seen from the repository root.</param> public AltinnCoreFile GetAltinnCoreFileByRealtivePath(string realtiveFilepath) { var absoluteFilepath = GetAbsoluteFilePathSanitized(realtiveFilepath); return(AltinnCoreFile.CreateFromPath(absoluteFilepath, RepositoryDirectory)); }
public void CreateFromPath_InvalidPath_ShouldThrowFileNotFoundException(string repositoryRootPath) { var filePath = $"{repositoryRootPath}\\myimaginary.schema.json"; Assert.Throws <FileNotFoundException>(() => AltinnCoreFile.CreateFromPath(filePath, repositoryRootPath)); }