### Create a Snapshot in an xUnit Test (C#) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/get-started.md Example of an xUnit test method demonstrating how to use `Snapshot.Match()` to create or compare a snapshot of a test result object (`person`). The first run creates the snapshot file, subsequent runs compare against it. ```csharp [Fact] public void CreatePersonSnapshotTest() { // arrange var serviceClient = new ServiceClient(); // act TestPerson person = serviceClient.CreatePerson( Guid.Parse("2292F21C-8501-4771-A070-C79C7C7EF451"), "David", "Mustermann"); // assert Snapshot.Match(person); } ``` -------------------------------- ### Starting Documentation with Docker - Bash Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/README.md Starts the documentation website locally using Docker Compose. This command assumes Docker is installed and configured. ```bash docker-compose up ``` -------------------------------- ### Install Snapshooter with dotnet CLI (Bash) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/get-started.md Command to add the Snapshooter NuGet package for xUnit using the .NET command-line interface. This is the first step to integrate Snapshooter into an xUnit test project. ```bash dotnet add package Snapshooter.Xunit ``` -------------------------------- ### Starting Documentation without Docker - Bash Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/README.md Starts the documentation website locally using Yarn. This method requires Node.js and Yarn to be installed on the system. ```bash cd website yarn yarn start ``` -------------------------------- ### Example New Docusaurus Doc Markdown - Markdown Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Provides an example of the frontmatter and content for a new Docusaurus documentation file (`.md`). The frontmatter requires a unique `id` and a `title`. ```markdown --- id: newly-created-doc title: This Doc Needs To Be Edited --- My new content here.. ``` -------------------------------- ### Start Docusaurus Development Server - Shell Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Starts the local development server for the Docusaurus website, allowing live preview of changes. The server typically runs on a local port like 3000. ```sh # Start the site $ yarn start ``` -------------------------------- ### Install Docusaurus Dependencies - Shell Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Installs the necessary project dependencies for the Docusaurus website using Yarn. This command should be run in the project's root directory after cloning. ```sh # Install dependencies $ yarn ``` -------------------------------- ### Add Doc to Docusaurus Sidebar - Javascript Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Demonstrates how to add a new documentation page ID (`newly-created-doc`) to an existing category ('Getting Started') within the `website/sidebar.json` configuration file. This makes the new doc appear in the sidebar navigation. ```javascript // Add newly-created-doc to the Getting Started category of docs { "docs": { "Getting Started": [ "quick-start", "newly-created-doc" // new doc here ], ... }, ... } ``` -------------------------------- ### Example New Docusaurus Blog Post Markdown - Markdown Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Provides an example of the frontmatter, including author details (`author`, `authorURL`, `authorFBID`) and `title`, for a new Docusaurus blog post file (`.md`). Blog post filenames follow the `YYYY-MM-DD-Title.md` format. ```markdown --- author: Frank Li authorURL: https://twitter.com/foobarbaz authorFBID: 503283835 title: New Blog Post --- Lorem Ipsum... ``` -------------------------------- ### Example Docusaurus Blog Post Markdown - Markdown Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Shows the frontmatter and basic content structure for an existing Docusaurus blog post written in Markdown. The frontmatter includes the unique `id` and `title` for the post. ```markdown --- id: post-needs-edit title: This Blog Post Needs To Be Edited --- Edit me... ``` -------------------------------- ### Example Docusaurus Doc Markdown - Markdown Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Shows the frontmatter and basic content structure for an existing Docusaurus documentation page written in Markdown. The frontmatter includes the unique `id` and `title` for the document. ```markdown --- id: page-needs-edit title: This Doc Needs To Be Edited --- Edit me... ``` -------------------------------- ### Docusaurus Project Directory Structure - Text Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Illustrates the typical directory structure of a Docusaurus project. It shows the location of documentation files (`docs/`), blog posts (`website/blog/`), configuration files (`package.json`, `sidebar.json`, `siteConfig.js`), and static assets. ```text my-docusaurus/ docs/ doc-1.md doc-2.md doc-3.md website/ blog/ 2016-3-11-oldest-post.md 2017-10-24-newest-post.md core/ node_modules/ pages/ static/ css/ img/ package.json sidebar.json siteConfig.js ``` -------------------------------- ### Add Blog Link to Docusaurus Header - Javascript Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Shows how to add a link to the blog index in the `headerLinks` array within the `website/siteConfig.js` file. Setting `blog: true` automatically creates a link to the blog page. ```javascript headerLinks: [ ... { blog: true, label: 'Blog' }, ... ] ``` -------------------------------- ### Example Code Block Content Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/snapshot-naming.1.md This snippet contains placeholder text presented within a markdown code block. It serves as an example of how content appears when formatted as code. ```text Mauris vestibulum ullamcorper nibh, ut semper purus pulvinar ut. Donec volutpat orci sit amet mauris malesuada, non pulvinar augue aliquam. Vestibulum ultricies at urna ut suscipit. Morbi iaculis, erat at imperdiet semper, ipsum nulla sodales erat, eget tincidunt justo dui quis justo. Pellentesque dictum bibendum diam at aliquet. Sed pulvinar, dolor quis finibus ornare, eros odio facilisis erat, eu rhoncus nunc dui sed ex. Nunc gravida dui massa, sed ornare arcu tincidunt sit amet. Maecenas efficitur sapien neque, a laoreet libero feugiat ut. ``` -------------------------------- ### Add Links to Docusaurus Header - Javascript Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Illustrates how to add various types of links (links to docs using `doc`, links to custom pages using `page`, and external links using `href`) to the `headerLinks` array in `website/siteConfig.js`. Each link requires a `label`. ```javascript { headerLinks: [ ... /* you can add docs */ { doc: 'my-examples', label: 'Examples' }, /* you can add custom pages */ { page: 'help', label: 'Help' }, /* you can add external links */ { href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' }, ... ], ... } ``` -------------------------------- ### Example File Structure for Snapshot Mismatch - C# Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/snapshot-mismatch.md This snippet illustrates the directory structure created by Snapshooter when a snapshot mismatch occurs, showing the location of the original snapshot file and the newly saved mismatching snapshot file within the '__mismatch__' subfolder. ```csharp Snapshooter.Examples.Xunit.csproj │ ├── __snapshots__ │ ├── __mismatch__ │ │ └── MismatchTests.MismatchingSnapshot_ThrowsException.snap --> Mismatch │ └── MismatchTests.MismatchingSnapshot_ThrowsException.snap --> Original │ └── MismatchTests.cs ``` -------------------------------- ### Add Custom Page Link to Docusaurus Header - Javascript Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/website/README.md Shows how to add a link to a custom React page (defined as a `.js` file in `website/pages/en`) in the `headerLinks` array within the `website/siteConfig.js` file. Use the `page` property with the page's filename (without extension) and provide a `label`. ```javascript { headerLinks: [ ... { page: 'my-new-custom-page', label: 'My New Custom Page' }, ... ], ... } ``` -------------------------------- ### Matching Test Result with Snapshot (C#) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/basic-concept.md Demonstrates the core method used in Snapshooter to compare a test result object against a stored snapshot file. If a snapshot doesn't exist, it will be created; otherwise, the result is compared to the existing snapshot. ```C# Snapshot.Match(yourResultObject); ``` -------------------------------- ### Matching Snapshot with Name Extensions (C#) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/snapshot-naming.md This snippet demonstrates how to append additional values to the default snapshot name using SnapshotNameExtension.Create. The provided values are converted to strings and concatenated to the default name using underscores, allowing for dynamic naming while retaining the test context. ```csharp [Fact] public void CreatePerson_SnapshotNameWithNameExtensions_SnapshotWithdDefaultNameExtensions() { // arrange var serviceClient = new ServiceClient(); // act TestPerson person = serviceClient.CreatePerson( Guid.Parse("1192F21C-8501-4771-A070-C79C7C7EF411"), "Albert", "Einstein"); // assert // Snapshot name is NamingTests.CreatePerson_SnapshotNameWithNameExtensions_SnapshotWithdDefaultNameExtensions_Age_88_Prof.snap Snapshot.Match(person, SnapshotNameExtension.Create("Age", 88, "Prof")); } ``` -------------------------------- ### Matching Snapshot with Explicit Name (C#) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/snapshot-naming.md This snippet shows how to explicitly define a custom name for a snapshot by providing a string argument to the Snapshot.Match method. This overrides the default naming convention and results in a snapshot file named exactly as specified, followed by .snap. ```csharp [Fact] public void CreatePerson_DefinedSnapshotName_SnapshotWithDefinedName() { // arrange var serviceClient = new ServiceClient(); // act TestPerson person = serviceClient.CreatePerson( Guid.Parse("1192F21C-8501-4771-A070-C79C7C7EF411"), "Albert", "Einstein"); // assert // Snapshot name is ExplicitlyDefinedSnapshotName.snap Snapshot.Match(person, "ExplicitlyDefinedSnapshotName"); } ``` -------------------------------- ### Matching Snapshot with Default Name (C#) Source: https://github.com/swisslife-oss/snapshooter-docs/blob/master/docs/snapshot-naming.md This snippet demonstrates how Snapshooter automatically generates a unique snapshot name based on the test class and method names when no name is explicitly provided in the Snapshot.Match call. The resulting snapshot file name will follow the pattern ..snap. ```csharp [Fact] public void CreatePerson_DefaultSnapshotName_SnapshotWithDefaultName() { // arrange var serviceClient = new ServiceClient(); // act TestPerson person = serviceClient.CreatePerson( Guid.Parse("1192F21C-8501-4771-A070-C79C7C7EF411"), "Albert", "Einstein"); // assert // Snapshot name is NamingTests.CreatePerson_DefaultSnapshotName_SnapshotWithDefaultName.snap Snapshot.Match(person); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.