### VerifyFile("file.csv") Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Verifies a CSV file from disk. The file path is passed to Verify, which then uses the registered CSV scrubber to parse, normalize (replacing GUIDs and dates with tokens), and compare the content against a stored snapshot. ```APIDOC ## VerifyFile("file.csv") ### Description Passes a `.csv` file path directly to Verify. The registered CSV scrubber intercepts the file content, parses it with CsvHelper, normalizes all cells (replacing GUIDs and dates with deterministic tokens), and writes the result to the snapshot. On first run, a `.verified.csv` file is created; subsequent runs compare against it. ### Method `VerifyFile(string filePath)` ### Parameters #### Path Parameters - **filePath** (string) - Required - The path to the CSV file. ### Request Example ```csharp // Input: sample.csv // Index,Customer Id,First Name,Last Name,Dob // 1,44e0f9d9-e56e-4626-b88f-b29fecb8c584,Sheryl,Baxter,1/02/2025 // 2,e58dd853-3aa0-4360-9dd1-86be558a1ad8,Preston,Lozano,2/02/2025 [TestFixture] public class CsvTests { [Test] public Task VerifyCsv() => VerifyFile("sample.csv"); } ``` ### Response Example ``` // Resulting snapshot: Samples.VerifyCsv.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` ``` -------------------------------- ### Verify CSV File Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Pass a .csv file path to Verify. The CSV scrubber will parse the file, normalize cells (replacing GUIDs and dates), and compare against the stored snapshot. A `.verified.csv` file is created on the first run. ```csharp // Input: sample.csv // Index,Customer Id,First Name,Last Name,Dob // 1,44e0f9d9-e56e-4626-b88f-b29fecb8c584,Sheryl,Baxter,1/02/2025 // 2,e58dd853-3aa0-4360-9dd1-86be558a1ad8,Preston,Lozano,2/02/2025 [TestFixture] public class CsvTests { [Test] public Task VerifyCsv() => VerifyFile("sample.csv"); } // Resulting snapshot: Samples.VerifyCsv.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` -------------------------------- ### Verified CSV Output Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md This is the expected output after verifying the 'sample.csv' file. Note that GUIDs and dates are scrubbed. ```csv Index,Customer Id,First Name,Last Name,Company,City,Country,Phone,Dob 1,Guid_1,Sheryl,Baxter,Rasmussen Group,East Leonard,Chile,229.077.5154,Date_1 2,Guid_2,Preston,Lozano,Vega-Gentry,East Jimmychester,Djibouti,5153435776,Date_2 3,Guid_3,Roy,Berry,Murillo-Perry,Isabelborough,Antigua and Barbuda,-1199,Date_3 4,Guid_4,Linda,Olsen,Mcmillan and Donovan,Bensonview,Dominican Republic,001-808-617-6467,Date_4 5,Guid_5,Joanna,Bender,Lang and Andrade,West Priscilla,Slovakia,001-234-203-0635,Date_5 6,Guid_6,Aimee,Downs,Steele Group,Chavezborough,Bosnia and Herzegovina,(283)437-3886,Date_6 7,Guid_7,Darren,Peck,Woodard and Mitchell,Lake Ana,Pitcairn Islands,(496)452-6181,Date_7 8,Guid_8,Brett,Mullen,Davenport and Giles,Kimport,Bulgaria,001-583-352-7197,Date_8 9,Guid_9,Sheryl,Meyers,Browning-Simon,Robersonstad,Cyprus,854-138-4911,Date_9 ``` -------------------------------- ### Initialize Verify.CsvHelper Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Call this once, typically from a [ModuleInitializer], before any tests run to register the CSV scrubber and CsvReader converter with the Verify framework. Subsequent calls will throw an exception. ```csharp using VerifyTests; // ModuleInitializer.cs — called automatically at assembly load time public static class ModuleInitializer { [ModuleInitializer] public static void Initialize() => VerifyCsvHelper.Initialize(); } // After calling Initialize(), VerifyCsvHelper.Initialized == true Console.WriteLine(VerifyCsvHelper.Initialized); // True ``` -------------------------------- ### Enable Verify.CsvHelper Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md Call this method in a module initializer to enable the Verify.CsvHelper extension for CSV file verification. ```cs [ModuleInitializer] public static void Initialize() => VerifyCsvHelper.Initialize(); ``` -------------------------------- ### VerifyCsvHelper.Initialize() Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Registers the CSV scrubber and CsvReader file converter with the Verify framework. This method should be called once before any tests run, typically from a ModuleInitializer. ```APIDOC ## VerifyCsvHelper.Initialize() ### Description Registers the CSV scrubber for string/file-based CSV content and a `CsvReader` converter for direct reader verification. Calling it more than once throws an `InvalidOperationException`. ### Method `VerifyCsvHelper.Initialize()` ### Usage Example ```csharp using VerifyTests; // ModuleInitializer.cs — called automatically at assembly load time public static class ModuleInitializer { [ModuleInitializer] public static void Initialize() => VerifyCsvHelper.Initialize(); } // After calling Initialize(), VerifyCsvHelper.Initialized == true Console.WriteLine(VerifyCsvHelper.Initialized); // True ``` ``` -------------------------------- ### Sample CSV Input Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md This is a sample CSV file content used for testing and verification. ```csv Index,Customer Id,First Name,Last Name,Company,City,Country,Phone,Dob 1,44e0f9d9-e56e-4626-b88f-b29fecb8c584,Sheryl,Baxter,Rasmussen Group,East Leonard,Chile,229.077.5154,1/02/2025 2,e58dd853-3aa0-4360-9dd1-86be558a1ad8,Preston,Lozano,Vega-Gentry,East Jimmychester,Djibouti,5153435776,2/02/2025 3,0de1d6ab-f7ad-455c-822e-fbe6e9b7e40a,Roy,Berry,Murillo-Perry,Isabelborough,Antigua and Barbuda,-1199,3/02/2025 4,c26c7ead-2f50-44a4-bba6-2dde0228f280,Linda,Olsen,Mcmillan and Donovan,Bensonview,Dominican Republic,001-808-617-6467,4/02/2025 5,e5f7febf-bedf-4f77-924d-472f30897928,Joanna,Bender,Lang and Andrade,West Priscilla,Slovakia,001-234-203-0635,5/02/2025 6,355a51db-8b9d-4210-bf50-b4a733080985,Aimee,Downs,Steele Group,Chavezborough,Bosnia and Herzegovina,(283)437-3886,6/02/2025 7,b9d9dc41-9fc3-49d8-a418-36229ceeba0f,Darren,Peck,Woodard and Mitchell,Lake Ana,Pitcairn Islands,(496)452-6181,7/02/2025 8,f7b4f884-0d6a-4ddb-b3ac-4235b06bf390,Brett,Mullen,Davenport and Giles,Kimport,Bulgaria,001-583-352-7197,8/02/2025 9,e2aafdb2-fb28-433a-96ad-cacac4f0daf4,Sheryl,Meyers,Browning-Simon,Robersonstad,Cyprus,854-138-4911,9/02/2025 ``` -------------------------------- ### Verify a CSV File Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md This test verifies a CSV file using the Verify.CsvHelper extension. It relies on the 'sample.csv' file being present. ```cs [Test] public Task VerifyCsv() => VerifyFile("sample.csv"); ``` -------------------------------- ### Verify(csvReader) Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Verifies a CsvHelper.CsvReader instance directly. This method is ideal when a CsvReader is already configured with custom settings, as it uses the existing configuration for normalization and verification. ```APIDOC ## Verify(csvReader) ### Description Passes a `CsvHelper.CsvReader` instance directly to Verify. The registered `CsvReader` file converter converts the reader's output into normalized CSV text and stores it as a `.csv` snapshot. This entry point is ideal when a `CsvReader` is already constructed with custom configuration (delimiters, encodings, mappings, etc.). ### Method `Verify(CsvReader csvReader)` ### Parameters #### Path Parameters - **csvReader** (CsvReader) - Required - The CsvReader instance to verify. ### Request Example ```csharp static CsvConfiguration config = new(CultureInfo.InvariantCulture) { NewLine = "\n" }; [Test] public Task VerifyReader() { using var reader = File.OpenText("sample.csv"); using var csvReader = new CsvReader(reader, config); return Verify(csvReader); } ``` ### Response Example ``` // Resulting snapshot: Samples.VerifyReader.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` ``` -------------------------------- ### Verify CsvReader Instance Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Pass a CsvHelper.CsvReader instance directly to Verify. The registered CsvReader file converter normalizes the reader's output into CSV text for snapshot comparison. This is ideal when a CsvReader is already configured with custom settings. ```csharp static CsvConfiguration config = new(CultureInfo.InvariantCulture) { NewLine = "\n" }; [Test] public Task VerifyReader() { using var reader = File.OpenText("sample.csv"); using var csvReader = new CsvReader(reader, config); return Verify(csvReader); } // Resulting snapshot: Samples.VerifyReader.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` -------------------------------- ### Verify CSV Stream Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Pass a raw Stream to Verify with the "csv" extension hint. The stream content is processed through the same normalization pipeline as file-based verification. This is useful for CSV data from HTTP responses or memory buffers. ```csharp [Test] public Task VerifyCsvStream() { var stream = File.OpenRead("sample.csv"); return Verify(stream, "csv"); } // Resulting snapshot: Samples.VerifyCsvStream.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` -------------------------------- ### Verify(stream, "csv") Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Verifies a CSV stream. The stream is provided to Verify with the "csv" extension hint, ensuring it goes through the same normalization pipeline as file-based verification. ```APIDOC ## Verify(stream, "csv") ### Description Passes a raw `Stream` to Verify with the `"csv"` extension hint. The stream content is routed through the same CSV scrubber pipeline as file-based verification. Useful when CSV data comes from HTTP responses, memory buffers, or other non-file sources. ### Method `Verify(Stream stream, string extension)` ### Parameters #### Path Parameters - **stream** (Stream) - Required - The stream containing CSV data. - **extension** (string) - Required - The extension hint, should be "csv". ### Request Example ```csharp [Test] public Task VerifyCsvStream() { var stream = File.OpenRead("sample.csv"); return Verify(stream, "csv"); } ``` ### Response Example ``` // Resulting snapshot: Samples.VerifyCsvStream.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,Guid_1,Sheryl,Baxter,Date_1 // 2,Guid_2,Preston,Lozano,Date_2 ``` ``` -------------------------------- ### Verify CSV Stream Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md Verifies a CSV file by reading it as a stream. Ensure the stream is properly opened and closed. ```cs [Test] public Task VerifyCsvStream() { var stream = File.OpenRead("sample.csv"); return Verify(stream, "csv"); } ``` -------------------------------- ### Scrub Columns in CSV Verification Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md Replaces the content of specified columns with '{Scrubbed}' during verification. Useful for sensitive or PII data. ```cs [Test] public Task ScrubCsvColumns() => VerifyFile("sample.csv") .ScrubCsvColumns("Customer Id"); ``` ```csv Index,Customer Id,First Name,Last Name,Company,City,Country,Phone,Dob 1,{Scrubbed},Sheryl,Baxter,Rasmussen Group,East Leonard,Chile,229.077.5154,Date_1 2,{Scrubbed},Preston,Lozano,Vega-Gentry,East Jimmychester,Djibouti,5153435776,Date_2 3,{Scrubbed},Roy,Berry,Murillo-Perry,Isabelborough,Antigua and Barbuda,-1199,Date_3 4,{Scrubbed},Linda,Olsen,Mcmillan and Donovan,Bensonview,Dominican Republic,001-808-617-6467,Date_4 5,{Scrubbed},Joanna,Bender,Lang and Andrade,West Priscilla,Slovakia,001-234-203-0635,Date_5 6,{Scrubbed},Aimee,Downs,Steele Group,Chavezborough,Bosnia and Herzegovina,(283)437-3886,Date_6 7,{Scrubbed},Darren,Peck,Woodard and Mitchell,Lake Ana,Pitcairn Islands,(496)452-6181,Date_7 8,{Scrubbed},Brett,Mullen,Davenport and Giles,Kimport,Bulgaria,001-583-352-7197,Date_8 9,{Scrubbed},Sheryl,Meyers,Browning-Simon,Robersonstad,Cyprus,854-138-4911,Date_9 ``` -------------------------------- ### Verify CSV Reader Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md Verifies CSV data directly from a CsvReader instance. Ensure the reader and its underlying stream are properly disposed. ```cs [Test] public Task VerifyReader() { using var reader = File.OpenText("sample.csv"); using var csvReader = new CsvReader(reader, config); return Verify(csvReader); } ``` -------------------------------- ### Translate CSV Columns Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Applies custom transformations to cell values within specified columns. Returns null to use default scrubbing or a function to transform each cell. This is the most powerful extension for domain-specific normalization. ```csharp // Custom transform: mask phone numbers, uppercase country names, // and fall back to default scrubbing for all other columns. [Test] public Task TranslateColumns() => VerifyFile("sample.csv") .TranslateCsvColumn(columnName => columnName switch { "Phone" => cellValue => cellValue is null ? null : "", "Country" => cellValue => cellValue?.ToUpperInvariant(), _ => null // null = use Verify's default GUID/date scrubbing }); // Resulting snapshot for rows 1-2: // Index,Customer Id,First Name,Last Name,Company,City,Country,Phone,Dob // 1,Guid_1,Sheryl,Baxter,Rasmussen Group,East Leonard,CHILE,,Date_1 // 2,Guid_2,Preston,Lozano,Vega-Gentry,East Jimmychester,DJIBOUTI,,Date_2 // Combining TranslateCsvColumn with ScrubCsvColumns and IgnoreCsvColumns: [Test] public Task CombinedColumnHandling() => VerifyFile("sample.csv") .IgnoreCsvColumns("Index") .ScrubCsvColumns("Customer Id") .TranslateCsvColumn(col => col == "Country" ? value => value?.ToUpperInvariant() : null); ``` -------------------------------- ### Scrub CSV Columns Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Replaces values in specified columns with '{Scrubbed}' while preserving the header. Use to hide sensitive or non-deterministic data. Multiple columns can be scrubbed at once. ```csharp // Input: sample.csv has columns: Index, Customer Id, First Name, Last Name, Dob [Test] public Task ScrubCsvColumns() => VerifyFile("sample.csv") .ScrubCsvColumns("Customer Id"); // Resulting snapshot: Samples.ScrubCsvColumns.verified.csv // Index,Customer Id,First Name,Last Name,Dob // 1,{Scrubbed},Sheryl,Baxter,Date_1 // 2,{Scrubbed},Preston,Lozano,Date_2 // — Column header "Customer Id" is preserved; all values replaced with {Scrubbed} — // Scrub multiple columns at once: [Test] public Task ScrubMultipleColumns() => VerifyFile("sample.csv") .ScrubCsvColumns("Customer Id", "Phone"); ``` -------------------------------- ### Ignore Columns in CSV Verification Source: https://github.com/verifytests/verify.csvhelper/blob/main/readme.md Excludes specified columns from the CSV output during verification. Use this when certain columns contain dynamic or irrelevant data. ```cs [Test] public Task IgnoreColumns() => VerifyFile("sample.csv") .IgnoreCsvColumns("Customer Id"); ``` ```csv Index,First Name,Last Name,Company,City,Country,Phone,Dob 1,Sheryl,Baxter,Rasmussen Group,East Leonard,Chile,229.077.5154,Date_1 2,Preston,Lozano,Vega-Gentry,East Jimmychester,Djibouti,5153435776,Date_2 3,Roy,Berry,Murillo-Perry,Isabelborough,Antigua and Barbuda,-1199,Date_3 4,Linda,Olsen,Mcmillan and Donovan,Bensonview,Dominican Republic,001-808-617-6467,Date_4 5,Joanna,Bender,Lang and Andrade,West Priscilla,Slovakia,001-234-203-0635,Date_5 6,Aimee,Downs,Steele Group,Chavezborough,Bosnia and Herzegovina,(283)437-3886,Date_6 7,Darren,Peck,Woodard and Mitchell,Lake Ana,Pitcairn Islands,(496)452-6181,Date_7 8,Brett,Mullen,Davenport and Giles,Kimport,Bulgaria,001-583-352-7197,Date_8 9,Sheryl,Meyers,Browning-Simon,Robersonstad,Cyprus,854-138-4911,Date_9 ``` -------------------------------- ### Ignore CSV Columns Source: https://context7.com/verifytests/verify.csvhelper/llms.txt Removes specified columns entirely from CSV snapshots. Use for columns without assertion value like IDs. Can be used with explicit VerifySettings. ```csharp // Input: sample.csv has columns: Index, Customer Id, First Name, Last Name, Dob [Test] public Task IgnoreColumns() => VerifyFile("sample.csv") .IgnoreCsvColumns("Customer Id"); // Resulting snapshot: Samples.IgnoreColumns.verified.csv // Index,First Name,Last Name,Dob // 1,Sheryl,Baxter,Date_1 // 2,Preston,Lozano,Date_2 // — "Customer Id" column is completely absent from header and all rows — // Can also be used with explicit VerifySettings: [Test] public Task IgnoreColumnsWithSettings() { var settings = new VerifySettings(); settings.IgnoreCsvColumns("Customer Id", "Phone"); return VerifyFile("sample.csv", settings); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.