Many.Mocks
0.3.7
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Many.Mocks --version 0.3.7
NuGet\Install-Package Many.Mocks -Version 0.3.7
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="Many.Mocks" Version="0.3.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Many.Mocks --version 0.3.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Many.Mocks, 0.3.7"
#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.
// Install Many.Mocks as a Cake Addin #addin nuget:?package=Many.Mocks&version=0.3.7 // Install Many.Mocks as a Cake Tool #tool nuget:?package=Many.Mocks&version=0.3.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Many.Mocks
Time-saving extensions to create and setup large number of mocks using Moq framework.
How to use
You have a class with lots of mocks...
public class UserManager : UserManager<User>
{
/// <summary>
/// Ctor. 1
/// </summary>
public UserManager(IUserStore<User> store,
IOptions<IdentityOptions> optionsAccessor)
{
}
/// <summary>
/// Ctor. 2
/// </summary>
public UserManager(IUserStore<User> store,
IOptions<IdentityOptions> optionsAccessor,
IPasswordHasher<User> passwordHasher,
IEnumerable<IUserValidator<User>> userValidators,
IEnumerable<IPasswordValidator<User>> passwordValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
IServiceProvider services,
ILogger<UserManager<User>> logger)
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
{
}
public void Method(IUserPasswordStore<User> store) { ... }
public void Method(IUserStore<TUser> store) { ... }
}
How to generate a bunch of mocks from any method or constructor?
- You can get a bag of nedeed mocks just typing:
var mocks = typeof(UserManager).GetMocksFromConstructors(); //11 mocks: 2 from ctor. 1 and 9 from ctor. 2
- And also you can get only mocks from one specific constructor:
var mocks = typeof(UserManager).GetMocksFromConstructors(new List<Type>{ typeof(IUserStore<User>), typeof(IOptions<IdentityOptions>) }); //2 mocks from ctor. 1
- Same works for any method:
var mocks = typeof(UserManager).GetMocksFrom("method", new List<Type>{ typeof(IUserPasswordStore<User>) }); //1 mock
If a class is not proxiable and no mock can be created you can check it in the details:
var noMockCouldBeGeneratedForTheseClasses = mocks.Mocks.Where(p => !p.Generated); //Get the errors
var ex = noMockCouldBeGeneratedForTheseClasses.Error; //The thrown exception during mock generation
How to instantiate a class injecting a bunch of mocks?
var mocks = typeof(UserManager).GetMocksFromConstructors().Extract(); //Get just mocks
var result = mocks.UseToTryInstantiate(out UserManager result); //Get the instance
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos 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 | |
---|---|---|---|
3.0.0-beta1 | 262 | 4/7/2022 | |
2.1.0 | 542 | 3/31/2022 | |
2.0.0 | 376 | 12/6/2021 | |
1.1.0 | 497 | 11/29/2020 | |
1.0.0 | 2,989 | 6/12/2020 | |
0.5.0 | 787 | 6/11/2020 | |
0.3.7 | 820 | 11/25/2019 | |
0.3.6 | 714 | 11/22/2019 | |
0.3.5 | 737 | 11/22/2019 | |
0.3.4 | 697 | 11/20/2019 | |
0.3.3 | 692 | 11/19/2019 | |
0.3.2 | 687 | 11/19/2019 | |
0.3.1 | 717 | 11/19/2019 | |
0.3.0-beta1 | 579 | 11/19/2019 | |
0.2.0-beta1 | 537 | 11/18/2019 |