Skip to content

Kuinox/Myna

Repository files navigation

Myna

Myna: A drop-in alternative to Moq®️, capable of mocking interfaces and any class without an interface.

$\textcolor{gray}{\textsf{The Myna bird is known for its ability to mimic a wide range of sounds.}}$

NuGet Version

In order to use it, you can replace your Moq®️ package reference with:

<PackageReference Include="Myna.TheFatChicken" Version="0.1.1" />

Without Myna, using only Moq®️:

var mock = new Mock<IFoo>();
mock.Setup(x => x.Mocked).Returns(true);
Assert.IsTrue(mock.Object.Mocked);

interface IFoo
{
    public bool Mocked { get; }
}

class Foo : IFoo
{
   public bool Mocked => false;
}

With Myna:

var mock = new Mock<Foo>();
mock.Setup(x => x.Mocked).Returns(true);
Assert.IsTrue(mock.Object.Mocked);

class Foo
{
   public bool Mocked => false;
}

You don't need to pollute your codebase anymore with useless interfaces!

How does it work ?

In order to be able to Mock any class, Myna transparently weaves the DLLs after your project has compiled. It means it can only mock classes of DLLs that are copied to the output directory, so for example, you cannot mock .NET librairies, thankfully.

NuGet Packages

Myna was designed to support other Mocking libraries, but as of right now, only Moq®️ is implemented.

Package Name Description
Myna.API Contains the class proxy that gets injected into your classes.
Myna.Build An MSBuild task that runs the weaver on the assemblies.
Myna.TheFatChicken A Moq®️ fork that uses the class proxy from Myna.API. It also depends on Myna.Build so you only need to depends on this.

Documentation

There is no special API to know, everything should work transparently! (if not, feel free to open an issue)
You can just create a Mock of a class and it should work!
For the API documentation itself, you can refer to Moq®️ docs

The Fat Chicken ?!?

https://www.youtube.com/watch?v=bFIR2XIMQfQ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published