Skip to content
Mockito-like annotations for .NET
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
MockAttributes.Demo
MockAttributes
.gitignore
.travis.yml
MockAttributes.sln
README.md

README.md

MockAttributes

Build Status NuGet

Mockito-like annotations for .NET

See MovieFinderTest for a usage example

Installation

Visual Studio Package Manager Console:

Install-Package MockAttributes

Nuget:

nuget install MockAttributes

dotnet core:

dotnet add package MockAttributes

Usage

By default, MockAttributes assumes you're using Moq, so that it can extract the proxy object generated by Castle DynamicProxy and inject it into the class-under-test.

If you're using hand-rolled mocks or your mocking library doesn't wrap a class around the proxy object in the way that Moq does, you can pass an instance of DefaultProxyObjectExtractor into MockInjector.Inject.

For any other cases, you can implement IProxyObjectExtractor.

WIP

  • inject mocks into test class
  • inject mocked objects into class-under-test (for Moq initially, although could be made more general)
  • stand-up class-under-test with mocked objects
  • suppress CS0649 ("Field is never assigned to, and will always have its default value null")
  • support properties
  • unit tests
  • handle classes with multiple dependencies of the same type
  • fallback to property injection if no suitable constructors are found
You can’t perform that action at this time.