Skip to content

Extends Verify to allow verification of documents via Sylvan.Data.Excel.

License

Notifications You must be signed in to change notification settings

VerifyTests/Verify.Sylvan.Data.Excel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verify.Sylvan.Data.Excel

Discussions Build status NuGet Status

Code provided by Cédric Luthi https://github.com/0xced

Extends Verify to allow verification of Excel documents via Sylvan.Data.Excel.

Converts Excel documents (xls, xlsb and xlsx) to csv for verification.

See Milestones for release notes.

Sponsors

Entity Framework Extensions

Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.

Entity Framework Extensions

NuGet

Usage

Enable Verify.Sylvan.Data.Excel

[ModuleInitializer]
public static void Initialize() =>
    VerifySylvanDataExcel.Initialize();

snippet source | anchor

Excel

Verify a file

[Test]
public Task VerifyExcel() =>
    VerifyFile("sample.xlsx");

snippet source | anchor

Verify a Stream

[Test]
public Task VerifyExcelStream()
{
    var stream = new MemoryStream(File.ReadAllBytes("sample.xlsx"));
    return Verify(stream, "xlsx");
}

snippet source | anchor

Verify a ExcelDataReader

[Test]
public Task VerifyExcelDataReader()
{
    using var stream = File.OpenRead("sample.xlsx");
    using var reader = ExcelDataReader.Create(stream, ExcelWorkbookType.ExcelXml);
    return Verify(reader);
}

snippet source | anchor

Example snapshot

0,First Name,Last Name,Gender,Country,Date,Age,Id,Formula
1,Dulce,Abril,Female,United States,2017-10-15,32,1562,1594
2,Mara,Hashimoto,Female,Great Britain,2016-08-16,25,1582,1607
3,Philip,Gent,Male,France,2015-05-21,36,2587,2623
4,Kathleen,Hanner,Female,United States,2017-10-15,25,3549,3574
5,Nereida,Magwood,Female,United States,2016-08-16,58,2468,2526
6,Gaston,Brumm,Male,United States,2015-05-21,24,2554,2578

snippet source | anchor

CsvDataWriterOptions

Used to configure options for writing CSV data.

[Test]
public Task CsvDataWriterOptions()
{
    using var stream = File.OpenRead("sample.xlsx");
    var options = new CsvDataWriterOptions
    {
        Delimiter = '\t',
        Quote = '"',
    };

    return Verify(stream)
        .CsvDataWriterOptions(options);
}

snippet source | anchor

About

Extends Verify to allow verification of documents via Sylvan.Data.Excel.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Contributors 4

  •  
  •  
  •  
  •  

Languages