pulumi/sdk/dotnet/Pulumi/Testing/IMocks.cs
Sean Fausett 3530ba3205
[dotnet] Fix Resharper code issues (#7178)
* Fix resharper code issues for language usage opportunities

* Fix resharper code issues for common practices and code improvements

* Fix resharper code issues for potential code quality issues

* Fix resharper code issues for redundancies in code

* Fix xunit test output

* Update changelog

* Fix resharper code issues for compiler warnings

* Fix resharper code issues for inconsistent naming

* Add resharper solution settings file

* Fix resharper code issues for potential code quality issues

* Fix resharper code issues for redundancies in code

* Fix resharper code issues for redundancies in symbol declarations
2021-06-10 10:32:33 -04:00

82 lines
2.4 KiB
C#

// Copyright 2016-2020, Pulumi Corporation
using System.Collections.Immutable;
using System.Threading.Tasks;
namespace Pulumi.Testing
{
/// <summary>
/// Hooks to mock the engine that provide test doubles for offline unit testing of stacks.
/// </summary>
public interface IMocks
{
/// <summary>
/// Invoked when a new resource is created by the program.
/// </summary>
/// <param name="args">MockResourceArgs</param>
/// <returns>A tuple of a resource identifier and resource state. State can be either a POCO
/// or a dictionary bag. The returned ID may be null for component resources.</returns>
Task<(string? id, object state)> NewResourceAsync(MockResourceArgs args);
/// <summary>
/// Invoked when the program needs to call a provider to load data (e.g., to retrieve an existing
/// resource).
/// </summary>
/// <param name="args">MockCallArgs</param>
/// <returns>Invocation result, can be either a POCO or a dictionary bag.</returns>
Task<object> CallAsync(MockCallArgs args);
}
/// <summary>
/// MockResourceArgs for use in NewResourceAsync
/// </summary>
public class MockResourceArgs
{
/// <summary>
/// Resource type name.
/// </summary>
public string? Type { get; set; }
/// <summary>
/// Resource Name.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Dictionary of resource input properties.
/// </summary>
public ImmutableDictionary<string, object> Inputs { get; set; } = null!;
/// <summary>
/// Provider.
/// </summary>
public string? Provider { get; set; }
/// <summary>
/// Resource identifier.
/// </summary>
public string? Id { get; set; }
}
/// <summary>
/// MockCallArgs for use in CallAsync
/// </summary>
public class MockCallArgs
{
/// <summary>
/// Resource identifier.
/// </summary>
public string? Token { get; set; }
/// <summary>
/// Dictionary of input arguments.
/// </summary>
public ImmutableDictionary<string, object> Args { get; set; } = null!;
/// <summary>
/// Provider.
/// </summary>
public string? Provider { get; set; }
}
}