Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Using partial mocks for non public methods testing

, 10 Feb 2013
Pattern to follow using mock frameworks so non public methods can be tested. The code example is based on the RhinoMock framework but it is easily applicable to any other mock framework.
MockByExample.zip
MockByExample
.nuget
NuGet.exe
NuGet.targets
MockByExample
Calculators
Properties
Tests
packages
RhinoMocks.3.6.1
lib
net
Rhino.Mocks.dll
RhinoMocks.3.6.1.nupkg
RhinoMocks.3.6.1.nuspec

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MockByExample", "MockByExample\MockByExample.csproj", "{21CAFE9D-3561-4EF6-B7E3-949F46AE62CB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0FDADCF8-B687-427D-B672-D87B290C9374}"
	ProjectSection(SolutionItems) = preProject
		.nuget\NuGet.Config = .nuget\NuGet.Config
		.nuget\NuGet.exe = .nuget\NuGet.exe
		.nuget\NuGet.targets = .nuget\NuGet.targets
	EndProjectSection
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{21CAFE9D-3561-4EF6-B7E3-949F46AE62CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{21CAFE9D-3561-4EF6-B7E3-949F46AE62CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{21CAFE9D-3561-4EF6-B7E3-949F46AE62CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{21CAFE9D-3561-4EF6-B7E3-949F46AE62CB}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Enrique Albert
Software Developer (Senior)
Ireland Ireland
No Biography provided
Follow on   Twitter

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 10 Feb 2013
Article Copyright 2013 by Enrique Albert
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid