public void ReadData_ExplicitSubDir_ReturnResourceData() { var testData = new ResourceDataReader(typeof(ResourceDataReaderTest), "TestData"); var data = testData.ReadData("DataFile.txt"); data.Trim().Should().Be("DataFile"); }
public void GetResourceData_DefaultDir_ReturnResourceData() { var testData = new ResourceDataReader(typeof(ResourceDataReaderTest)); var data = testData.ReadData("DefaultDataFile.txt"); data.Trim().Should().Be("DefaultDataFile"); }
public void GetResourceData_NonexistentFile_Throw() { var testData = new ResourceDataReader(typeof(ResourceDataReaderTest)); Action act = () => testData.ReadData("DataFileWontBeFound.txt"); act.Should() .Throw <ArgumentException>() .WithMessage("Embedded resource not found*"); }
public ValueTask ExecuteAsync(IConsole console) { var reader = new ResourceDataReader(typeof(Program)); var ymlData = reader.ReadData("trash-config-template.yml"); if (_fileSystem.File.Exists(Path)) { throw new CommandException($"The file {Path} already exists. Please choose another path or " + "delete/move the existing file and run this command again."); } _fileSystem.File.WriteAllText(Path, ymlData); Log.Information("Created configuration at: {Path}", Path); return(default);
private static TextReader GetResourceData(string file) { var testData = new ResourceDataReader(typeof(ConfigurationLoaderTest), "Data"); return(new StringReader(testData.ReadData(file))); }