Skip to content

grzesiek-galezowski/any

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

282 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Any

⚠️ v11.0.0 contains breaking API changes. The import changed from using static TddXt.AnyRoot.Root to using 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.

NuGet

Requirements

  • .NET 10
  • C# 14

How to use?

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.

Extension method 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.

Extending the library

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.


CodeScene general

CodeScene Average Code Health

CodeScene Hotspot Code Health

CodeScene Missed Goals

CodeScene System Mastery

About

An anonymous object generator. Successor of Tdd Toolkit's Any class.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages