Skip to content
Akira Sugiura edited this page Feb 18, 2016 · 22 revisions

Welcome to the Prig wiki!

QUICK TOUR

Please see README.md!

[Source Code]

FEATURES

Calling Original Method

Depending on a test case, you may think that "I want to call original method, because I want to verify only the passed value." or "I want to just call indirectly at nth time". Prig provides the feature to call original method easily. For details, please see this page!

[Source Code]

Default Behavior

When you protect existing behavior via automated testing, tentatively, you may sometimes want to just check whether the method is called or not. For example, I guess there is the scene as follows: "I want to detect the invocation of any methods of the class Environment, because I want to know that whether the target method accesses the information of current environment, platform and so on." To achieve it, Prig supports the feature to modify the default behavior. For more details, please check this page!

[Source Code]

Generics

"How do I hijack a generic type or a generic method?", you may have question like that at least once if you use Microsoft Fakes. Certainly, Fakes can also replace generics, but the API is inconsistent from others. Prig provides more easy and consistent way. For details, please see this page!

[Source Code]

Non-public Method Replacement

Do you like extension methods? It should not be abused, but sometimes it can achieve natural API on the design if it is the function that you want the library to support essentially as its layer. However, whether the library is opened against such extension depends on circumstances. Specifically, note the case that a method having internal class in its signature pertains. This page describes how solve it by Prig!

[Source Code]

Cooperation with Other Frameworks

Prig doesn't support the feature of traditional mocking frameworks, because I believe it can be done by just using them if they are OSS library 😉 This page describes cooperation with Moq, NSubstitute, Rhino Mocks and FakeItEasy.

[Source Code]

Profilers Chain

The meaning of Profilers Chain is the feature that profilers are linked together and are run. You may think that "Are there any situation that links profilers together?". I believe it is yes. For details, please see this page!

[Source Code]

Replace Three or More out/ref Parameter Method

As you know, out/ref parameters should avoid to use because there are some warnings to note as below: CA1021: Avoid out parameters, CA1045: Do not pass types by reference and so on. Nevertheless, legacy code might not allow such rules. Prig supports a certain amount of the signature pattern same as Microsoft Fakes; otherwise you have to prepare it. We make up how to do that into this page.

[Source Code]

CHEAT SHEET

In this page, there are the method signatures that are supported by Prig and APIs that are explained in the above.

PACKAGE MANAGER CONSOLE POWERSHELL REFERENCE

This is the Package Manager Console Powershell reference to manage Prig. Please feel free to check them because they are no more than 5 commands ☺️

COMMAND LINE REFERENCE

To execute administrative operation -- enhance/reduce the scope of application of Prig, execute an external process under the Prig, confirm assembly summary using in Prig and so on --, you can use prig.exe. Its command line reference is here.

APPVEYOR SUPPORT

AppVeyor is a CI service that you can use free for OSS. Now, you can also run the unit test with Prig there! The way to install and test is here.

MIGRATION

From Microsoft Research Moles

Let's migrate the sample that mocks with Moles against the class that embraces "Event-based Asynchronous Pattern" to Prig(with Moq). For more details, please check this page!

[Source Code]

From Microsoft Fakes

This page introduces Fakes -> Prig migration. I take the migration explanation that is listed in the section "Migrating from commercial and open source frameworks" of the article "Better Unit Testing with Microsoft Fakes" for example. By the way, I believe that the way to leave Moq untouched is easier because Fakes has no features as a Mock Object, Umm... 😕

[Source Code]

From Telerik JustMock

[Source Code]

Part 1

This is one of the series that implements the samples that are in the official documents of JustMock. In this page, Final Mocking samples are migrated to Prig.

Part 2

This is one of the series that implements the samples that are in the official documents of JustMock, part 2. In this page, Sealed Mocking samples are migrated to Prig.

Part 3

This is one of the series that implements the samples that are in the official documents of JustMock, part 3. In this page, Static Mocking samples are migrated to Prig.

Test using MessageBox by Typemock Isolator

Typemock introduces the sample that replaces MessageBox to a mock in Isolator's Quick Start. Also, you can migrate it to Prig(with Moq).

[Source Code]

Clone this wiki locally