Pulumock 0.1.5

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

<p align="center"> <a href="https://github.com/Pulumock/Pulumock" title="Pulumock - A tool designed to address testing challenges in Pulumi .NET"> <img src="pulumock-logo.png" width="150" alt="Project logo" /> </a> </p>

License Release NuGet NuGet Pre-release NuGet downloads GitHub Discussions GitHub issues

Pulumock

Pulumock your stack before it bites back.

Pulumock is a testing tool for Pulumi .NET projects, designed to simplify and enhance unit testing. Built on top of the standard Pulumi .NET testing capabilities, it addresses common challenges reported by developers, based on real-world data from the Pulumissues dataset.

By using a fluent, strongly typed syntax, Pulumock abstracts away complexity and reduces boilerplate, letting you focus on test logic instead of setup. Pulumock also provides richer data for assertions, enabling more scenarios to be covered.

Table of Contents

Getting Started

Installation

Install the Pulumock NuGet package in your testing project:

dotnet add package Pulumock

Usage

Here’s a simple step-by-step example. For more in-depth instructions, see the documentation.

1. Create a FixtureBuilder

Begin by instantiating a FixtureBuilder in your test method or wherever appropriate in your codebase:

[Fact]
public async Task ExampleTest() 
{
    var fixtureBuilder = new FixtureBuilder();
}
2. Add Mocks

Add desired mocks:

[Fact]
public async Task ExampleTest() 
{
    var fixtureBuilder = new FixtureBuilder()
        .WithMockResource(new MockResourceBuilder<ResourceGroup>()
            .WithOutput(x => x.Location, "swedencentral")
            .Build()); 
}
3. Execute Test

Build the FixtureBuilder to run the Pulumi program in test mode, resulting in a Fixture object that captures the simulated deployment state without performing any real infrastructure changes:

[Fact]
public async Task ExampleTest() 
{
    var fixtureBuilder = new FixtureBuilder()
        .WithMockResource(new MockResourceBuilder<ResourceGroup>()
            .WithOutput(x => x.Location, "swedencentral")
            .Build()); 
    
    var fixture = await fixtureBuilder
        .BuildAsync(async () => await CoreStack.DefineResourcesAsync()); // Your code that creates resources.
}
4. Extract information & Write Assertions

Use convenient extension methods to extract information from the Fixture and write your assertions:

[Fact]
public async Task ExampleTest() 
{
    var fixtureBuilder = new FixtureBuilder()
        .WithMockResource(new MockResourceBuilder<ResourceGroup>()
            .WithOutput(x => x.Location, "swedencentral")
            .Build()); 
    
    var fixture = await fixtureBuilder
        .BuildAsync(async () => await CoreStack.DefineResourcesAsync()); // Your code that creates resources.
    
    var resourceGroup = fixture.Resources.Require<ResourceGroup>();
    var location = await resourceGroup.Location.GetValueAsync();
    
    location.ShouldBe("swedencentral");
}

Documentation

  • Explore the Wiki for official documentation and straightforward usage guides.
  • Check out the Example project for a working demonstration of Pulumock in action across multiple scenarios.

Contributing

See CONTRIBUTING.md for more information.

License

Pulumock is licensed under the MIT license. Feel free to edit and distribute this project as you like.

See LICENSE for more information.

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
0.1.5 110 5/9/2025
0.1.4 112 5/9/2025
0.1.3 107 5/4/2025
0.1.2 69 5/3/2025
0.1.1 66 5/3/2025
0.1.0 71 5/3/2025