示例#1
0
    public void ReadData_ExplicitSubDir_ReturnResourceData()
    {
        var testData = new ResourceDataReader(typeof(ResourceDataReaderTest), "TestData");
        var data     = testData.ReadData("DataFile.txt");

        data.Trim().Should().Be("DataFile");
    }
示例#2
0
    public void GetResourceData_DefaultDir_ReturnResourceData()
    {
        var testData = new ResourceDataReader(typeof(ResourceDataReaderTest));
        var data     = testData.ReadData("DefaultDataFile.txt");

        data.Trim().Should().Be("DefaultDataFile");
    }
示例#3
0
    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*");
    }
示例#4
0
    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);
示例#5
0
    private static TextReader GetResourceData(string file)
    {
        var testData = new ResourceDataReader(typeof(ConfigurationLoaderTest), "Data");

        return(new StringReader(testData.ReadData(file)));
    }