A mocking library based on the Compiler APIs (Roslyn + Mocks)
Switch branches/tags
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Images #45 Fixed obsolete type issue May 19, 2017
Rocks.PackageUsage.NETCore Updated for 3.1.0 publish Nov 4, 2017
Rocks.PackageUsage.NETFramework Updated for 3.1.0 publish Nov 4, 2017
Rocks.RockAssemblyTestContainer Cleaned up csproj files Feb 25, 2018
Rocks.Sketchpad Lots of little changes for performance and testing Jul 24, 2018
Rocks.Task.Tests Lots of little changes for performance and testing Jul 24, 2018
Rocks.Task Cleaned up csproj files Feb 25, 2018
Rocks.Tests.Types Lots of little changes for performance and testing Jul 24, 2018
Rocks.Tests Lots of little changes for performance and testing Jul 24, 2018
Rocks Lots of little changes for performance and testing Jul 24, 2018
.NET Core Refactor Issues #40 .NET Core support is finished! May 1, 2017
.NET Standard 2.0 Update Update to notes Sep 26, 2017
.editorconfig #48 .editorconfig added May 3, 2017
.gitattributes 💥🐫 Added .gitattributes & .gitignore files Feb 9, 2015
.gitignore Added Assembly-to-MetadataReference caching Nov 2, 2017
FxCopAnalyzers.ruleset Cleaned up csproj files Feb 25, 2018
LICENSE Create LICENSE Apr 30, 2017
PerformanceResults.txt Revert "#46 Tried new alpha package for NUnit testing....no luck :(" May 5, 2017
Problems With Handling mscorlib.txt Validate() needs to catch when type has internal constructors Apr 30, 2015
README.md Update README.md Sep 22, 2015
Result.png #40 more data gathering to solve issue Apr 6, 2017
Rocks.PackageUsage.sln #40 .NET Core support is finished! May 1, 2017
Rocks.sln Reduced Rocks.Tests to just one project Feb 26, 2018
Tests.runsettings Updated packages and uploaded 1.0.0 version to NuGet Jan 29, 2016

README.md

Rocks

A mocking library based on the Compiler APIs (Roslyn + Mocks)

There are great mocking libraries out there, like Moq (https://github.com/Moq/moq4) and NSubstitute (http://nsubstitute.github.io/), so why create YAML (yet another mocking library)? There are essentially two reasons.

The first reason relates to how code generation was done with mocking libraries. Most (if not all) use an approach that ends up using System.Reflection.Emit, which requires knowledge of IL. This is not a trivial endeavour. Furthermore, the generated code can't be stepped into during a debugging process. I wanted to write a mocking library with the new Compiler APIs (Roslyn) to see if I could make the code generation process for the mock much easier and allow a developer to step into that code if necessary.

The other reason is being able to pre-generate the mocks for a given assembly, rather than dynamically generate them in a test. This is what the Fakes library can do (https://msdn.microsoft.com/en-us/library/hh549175.aspx), but I wanted to be able to do it where I could easily modify a project file and automatically generate those mocks.

This is what Rocks can do. Mocks are created by generating C# code on the fly and compiling it with the Compiler APIs. This makes it trivial to step into the mock code. You can also pre-generate the mocks into its own assembly and reference that in your tests if you like.

So, feel free to test Rocks out, and see what you think. Even if you don't use it as your primary mocking library, you may see just how easy it to generate code on the fly with the new Compiler APIs. Enjoy!