Enigmatry.Entry.SmartEnums.VerifyTests 9.1.1-preview.4

This is a prerelease version of Enigmatry.Entry.SmartEnums.VerifyTests.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Enigmatry.Entry.SmartEnums.VerifyTests --version 9.1.1-preview.4
                    
NuGet\Install-Package Enigmatry.Entry.SmartEnums.VerifyTests -Version 9.1.1-preview.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Enigmatry.Entry.SmartEnums.VerifyTests" Version="9.1.1-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enigmatry.Entry.SmartEnums.VerifyTests" Version="9.1.1-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.SmartEnums.VerifyTests" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Enigmatry.Entry.SmartEnums.VerifyTests --version 9.1.1-preview.4
                    
#r "nuget: Enigmatry.Entry.SmartEnums.VerifyTests, 9.1.1-preview.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Enigmatry.Entry.SmartEnums.VerifyTests@9.1.1-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Enigmatry.Entry.SmartEnums.VerifyTests&version=9.1.1-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.SmartEnums.VerifyTests&version=9.1.1-preview.4&prerelease
                    
Install as a Cake Tool

Smart Enums VerifyTests

A library that provides testing utilities for Smart Enums using the Verify testing approach, allowing for snapshot testing of Smart Enum behaviors and serialization.

Intended Usage

Use this library when you need to write tests for Smart Enum types using the Verify snapshot testing approach. It helps validate that your Smart Enums behave consistently and serialize correctly.

Installation

Add the package to your project:

dotnet add package Enigmatry.Entry.SmartEnums.VerifyTests

Usage Example

using Enigmatry.Entry.SmartEnums;
using Enigmatry.Entry.SmartEnums.VerifyTests;
using System.Reflection;
using Argon;
using NUnit.Framework;
using VerifyNUnit;

namespace YourProject.Tests
{
    [TestFixture]
    public class ProductCategoryTests
    {
        private VerifySettings verifySettings;
        
        [SetUp]
        public void Setup()
        {
            // Create and configure VerifySettings for tests
            verifySettings = new VerifySettings();
            
            // Register SmartEnum converters for the Argon JSON serializer used by VerifyTests
            var converters = new List<JsonConverter>();
            converters.EntryAddSmartEnumJsonConverters(new[] { Assembly.GetExecutingAssembly() });
            
            // Add the converters to the serialization pipeline
            verifySettings.UseJsonSerializerSettings(settings => 
            {
                foreach (var converter in converters)
                {
                    settings.Converters.Add(converter);
                }
            });
        }        
        
        [Test]
        public Task Should_Verify_All_ProductCategories()
        {
            // Arrange & Act
            var allCategories = ProductCategory.List();
            
            // Assert
            // The SmartEnumWriteOnlyJsonConverter will serialize each SmartEnum using its Name property
            return Verifier.Verify(allCategories, verifySettings);
        }
        
        [Test]
        public Task Should_Verify_ProductCategory_Properties()
        {
            // Arrange & Act
            var electronics = ProductCategory.Electronics;
            
            // Assert
            return Verifier.Verify(electronics, verifySettings);
        }
        
        [Test]
        public Task Should_Serialize_SmartEnum_With_Custom_Properties()
        {
            // Arrange
            var category = ProductCategory.Electronics;
            
            // Act - Create a test object with the SmartEnum
            var testObject = new 
            {
                Category = category,
                CategoryName = category.Name,
                CategoryId = category.Value,
                DisplayName = category.DisplayName,
                IsDigital = category.IsDigitalProduct
            };
            
            // Assert
            // The SmartEnumWriteOnlyJsonConverter will handle proper serialization
            return Verifier.Verify(testObject, verifySettings);
        }
    }
    
    // Example Smart Enum based on typical Enigmatry.Entry.SmartEnums pattern
    public class ProductCategory : SmartEnum<ProductCategory>
    {
        public static readonly ProductCategory Electronics = new(1, nameof(Electronics), "Electronics & Tech", true);
        public static readonly ProductCategory Clothing = new(2, nameof(Clothing), "Apparel & Fashion", false);
        public static readonly ProductCategory Books = new(3, nameof(Books), "Books & Media", false);
        public static readonly ProductCategory DigitalContent = new(4, nameof(DigitalContent), "Digital Downloads", true);

        public string DisplayName { get; }
        public bool IsDigitalProduct { get; }

        private ProductCategory(int id, string name, string displayName, bool isDigitalProduct) 
            : base(id, name)
        {
            DisplayName = displayName;
            IsDigitalProduct = isDigitalProduct;
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.1-preview.5 177 8/8/2025
9.1.1-preview.4 90 6/27/2025
9.1.1-preview.3 133 6/4/2025
9.1.0 149 6/3/2025
9.0.1-preview.8 130 5/26/2025
9.0.1-preview.7 215 5/13/2025
9.0.1-preview.6 297 5/9/2025
9.0.1-preview.5 158 5/7/2025
9.0.1-preview.4 127 4/30/2025
9.0.1-preview.2 144 4/1/2025
9.0.0 168 2/26/2025
8.1.1-preview.3 127 5/7/2025
8.1.1-preview.1 139 4/1/2025
8.1.0 309 2/19/2025
8.0.1-preview.4 81 2/7/2025
8.0.1-preview.2 65 1/15/2025
8.0.0 742 11/27/2024
3.4.6-preview.10 72 11/27/2024
3.4.3 412 10/22/2024
3.4.2 477 10/11/2024
3.4.1 120 10/9/2024
3.4.0 115 10/9/2024
3.3.2 259 8/28/2024
3.3.2-preview.7 97 8/27/2024