⚠️ v11.0.0 contains breaking API changes. The import changed fromusing static TddXt.AnyRoot.Roottousing TddXt.AnyRoot. Call-site syntax is unchanged. See the Changelog and the Migration Guide.
An anonymous object generator for .NET tests. Successor of Tdd Toolkit's Any class.
- .NET 10
- C# 14
Install the Any NuGet package, then add a global using to your test project:
global using TddXt.AnyRoot;This will allow you to use several core methods like Any.Instance<T>():
var anInt = Any.Instance<int>();Most features are provided through extension methods on the Any class, which live in separate namespaces.
Most features are provided through extension methods on the Any class. Your IDE can add the imports for you, but the full list is:
using TddXt.AnyRoot.Collections;
using TddXt.AnyRoot.Enums;
using TddXt.AnyRoot.Exploding;
using TddXt.AnyRoot.Invokable;
using TddXt.AnyRoot.Math;
using TddXt.AnyRoot.Network;
using TddXt.AnyRoot.Numbers;
using TddXt.AnyRoot.Reflection;
using TddXt.AnyRoot.Strings;
using TddXt.AnyRoot.Time;You can add these as global usings if that is more convenient.
You can write your own extension methods on the Any class to add domain-specific generators:
using TddXt.AnyRoot;
namespace MyProject.TestHelpers;
public static class MyDomainExtensions
{
extension(Any)
{
public static Money Money()
{
return new Money(Any.Instance<decimal>(), Any.Instance<Currency>());
}
}
}Then use it like any built-in method:
var money = Any.Money();See the Migration Guide if you are upgrading existing custom extensions from a previous version.