Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mockable

A .NET attribute that enables controller methods to provide a mock.

Usage

Add the [Mockable] attribute to any controller method.

Optionally, provide a MockableCondition to only mock when certain conditions are met.

If no MockableCondition is provided, the default behavior is to never mock.

using Mockable.Attributes;

[ApiController]
public class SomeController : ControllerBase
{
    public string EndpointWithoutMock() => "This is not configured to mock.";

    [Mockable]
    public string EndpointToNeverMock() => "This will never be mocked.";

    [Mockable(Condition = MockableCondition.Always)]
    public string EndpointToAlwaysMock() => "This will be mocked.";

    [Mockable(Condition = MockableCondition.Always)]
    public Task<string> AsyncEndpointToAlwaysMock() => await Task.FromResult("This async result will be mocked.");
}

Roadmap

  • Scaffold attribute
  • Scaffold middleware
  • Mock simple types
  • Mock Task<> types
  • Enable conditions "Never" and "Always"
  • Enable "BadRequest", "Exception", and "UnableToConnect" conditions

About

A .NET attribute that enables controller methods to provide a mock.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages