Pillaro.Dataverse.PluginFramework.Testing 1.2.0

Prefix Reserved
dotnet add package Pillaro.Dataverse.PluginFramework.Testing --version 1.2.0
                    
NuGet\Install-Package Pillaro.Dataverse.PluginFramework.Testing -Version 1.2.0
                    
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="Pillaro.Dataverse.PluginFramework.Testing" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pillaro.Dataverse.PluginFramework.Testing" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Pillaro.Dataverse.PluginFramework.Testing" />
                    
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 Pillaro.Dataverse.PluginFramework.Testing --version 1.2.0
                    
#r "nuget: Pillaro.Dataverse.PluginFramework.Testing, 1.2.0"
                    
#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 Pillaro.Dataverse.PluginFramework.Testing@1.2.0
                    
#: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=Pillaro.Dataverse.PluginFramework.Testing&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Pillaro.Dataverse.PluginFramework.Testing&version=1.2.0
                    
Install as a Cake Tool

Pillaro.Dataverse.PluginFramework.Testing

A testing package focused on integration testing for Microsoft Dataverse solutions.

The package provides a structured and maintainable approach to testing Dataverse logic using real data, deterministic execution and automatic cleanup.


What this package provides

  • Infrastructure for integration testing against Microsoft Dataverse
  • Test DataService for working with Dataverse in test scenarios
  • Repository-based test data preparation
  • Automatic creation and cleanup of test data
  • Handling of referenced data that cannot be deleted directly
  • Structured test setup using fixtures and dependency injection

Why use it

  • Reduce complexity of Dataverse integration tests
  • Keep test data consistent and reusable
  • Automatically clean up test data after execution
  • Handle complex cleanup scenarios (relationships, references)
  • Improve long-term maintainability of test suite
  • Keep tests focused on behavior, not infrastructure

Testing approach

Each test follows a deterministic lifecycle:

  1. Prepare data using repositories
  2. Create data in Dataverse via DataService
  3. Execute tested logic (plugin / business operation)
  4. Verify result
  5. Automatically clean up all created data

This ensures tests are isolated, predictable and maintainable.


  • Repositories/
    Reusable test data definitions

  • Tests/
    Test scenarios (behavior only)

  • TestBase / Fixtures
    Shared setup (DI, lifecycle)

  • Infrastructure/Dataverse/
    TestDataService, cleanup, Dataverse access

  • AutoFacModule
    Dependency registration


Core concepts

TestDataService

Central entry point for test interaction with Dataverse.

  • creates entities
  • tracks created data
  • provides querying
  • ensures cleanup

Data repositories

Encapsulate test data creation.

  • reusable
  • centralized
  • resilient to schema changes

Automatic cleanup

  • deletes all created data
  • handles referenced entities
  • prevents test pollution

Autofac configuration

Tests use Autofac for dependency injection.

public class TestAutofacModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder.RegisterModule<FrameworkTestingAutofacModule>();

        builder.RegisterAssemblyTypes(GetType().Assembly)
            .Where(t => t.GetInterfaces().Any(i => i.IsAssignableFrom(typeof(IAutoRegisteredTestDataRepository))))
            .AsSelf();
    }
}

Custom TestBase

You can extend the base test class to include your own services:

public class TestBase : TestBase<TestAutofacModule>
{
    protected readonly SettingsService SettingService;

    public TestBase(TestFixture<TestAutofacModule> testFixture, ITestOutputHelper output)
        : base(testFixture, output)
    {
        SettingService = testFixture.Container.Resolve<SettingsService>();
    }
}

Example test class

[Trait("Owner", "JM")]
[Trait("Category", nameof(TestTask))]
public class TestTaskTest(TestFixture<TestAutofacModule> testFixture, ITestOutputHelper output) : TestBase(testFixture, output)
{
    [Fact]
    public void Valid_Firstname_And_Lastname()
    {
        var contact = new Contact
        {
            FirstName = "Jan",
            LastName = "Mucha"
        };

        contact.Id = TestDataService.CreateTestEntity(contact);

        var loaded = TestDataService
            .Query<Contact>()
            .Where(x => x.Id == contact.Id)
            .Select(x => new Contact { FirstName = x.FirstName, LastName = x.LastName })
            .First();

        Assert.Equal(contact.FirstName, loaded.FirstName);
        Assert.Equal(contact.LastName, loaded.LastName);
    }
}

Each test should:

  • use repositories for data preparation
  • use TestDataService for all Dataverse interaction
  • focus only on behavior validation
  • rely on automatic cleanup

Avoid:

  • manual entity construction inside tests
  • manual cleanup logic
  • duplicated data setup

Maintainability strategy

The package is designed to reduce long-term cost of test maintenance:

  • centralized data definitions (repositories)
  • deterministic execution
  • automatic cleanup

Result:

  • easier refactoring
  • lower maintenance cost
  • higher clarity

Where to find more


License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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
1.2.0 86 9/9/2026
1.2.0-rc.569 62 9/6/2026
1.2.0-rc.559 60 9/6/2026
1.1.3-rc.550 60 9/5/2026
1.1.3-rc.542 57 9/4/2026
1.1.2 89 8/31/2026
1.1.1 127 7/27/2026
1.1.1-rc.428 59 7/20/2026
1.1.0 143 6/7/2026
1.1.0-rc.257 73 6/2/2026
1.1.0-rc.252 63 6/2/2026
1.1.0-rc.248 68 6/1/2026
1.1.0-rc.244 67 6/1/2026
1.0.2 109 5/6/2026
1.0.2-rc.141 63 5/4/2026
1.0.1-rc.115 71 4/14/2026
1.0.1-rc.114 76 4/14/2026
1.0.1-ci.109 83 4/12/2026
1.0.0-ci.108 75 4/12/2026
1.0.0-ci.107 76 4/11/2026
Loading failed