{"id":170392,"date":"2010-01-25T15:55:21","date_gmt":"2010-01-25T15:55:21","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/research\/project\/moles-isolation-framework-for-net\/"},"modified":"2017-05-31T15:38:32","modified_gmt":"2017-05-31T22:38:32","slug":"moles-isolation-framework-for-net","status":"publish","type":"msr-project","link":"https:\/\/www.microsoft.com\/en-us\/research\/project\/moles-isolation-framework-for-net\/","title":{"rendered":"Moles &#8211; Isolation framework for .NET"},"content":{"rendered":"<p class=\"asset-content\">Moles allows to replace any .NET method with a delegate. Moles supports static or non-virtual methods. Moles works well with Pex.<!-- .asset-content --><\/p>\n<div id=\"en-usprojectsmolesdefault\" class=\"page-content\">\n<p><a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/hh549175(v=vs.110).aspx\"><b>The Fakes Framework in Visual Studio\u00a02012 is the next generation of Moles & Stubs.<\/b><span class=\"sr-only\"> (opens in new tab)<\/span><\/a> Fakes is different from Moles, however, so moving from Moles to Fakes will require some modifications to your code. The Moles framework\u00a0will\u00a0not be supported in Visual Studio 2012.<\/p>\n<ul>\n<li><a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"http:\/\/www.peterprovost.org\/blog\/2012\/04\/15\/visual-studio-11-fakes-part-1\/\">Read the blog post from Peter Provost about Stubs<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>.<\/li>\n<li><a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"http:\/\/www.peterprovost.org\/blog\/2012\/04\/25\/visual-studio-11-fakes-part-2\/\">Read the blog post from Peter Provost about Shims.<span class=\"sr-only\"> (opens in new tab)<\/span><\/a><\/li>\n<li><a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/hh549175(v=vs.110).aspx\">Learn more about the Fakes Framework on MSDN<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>.<\/li>\n<\/ul>\n<\/div>\n<div id=\"en-usprojectsmolesdefault\" class=\"page-content\">\n<p><span id=\"8c1886a1-4a1d-4886-9c59-999153f8db52\" class=\"ImageBlock fn\"><img decoding=\"async\" id=\"Image8c1886a1-4a1d-4886-9c59-999153f8db52\" src=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2016\/02\/stubs-y2kbug.png\" alt=\"\" \/><span id=\"ImageCaption8c1886a1-4a1d-4886-9c59-999153f8db52\" class=\"ImageCaptionCoreCss ImageCaption\"><\/span><\/span><\/p>\n<p><b>Replace any .NET method with your own delegate! <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" href=\"http:\/\/channel9.msdn.com\/posts\/Peli\/Moles-Replace-any-NET-method-with-a-delegate\/\" target=\"_blank\">Watch the video (5min)!<span class=\"sr-only\"> (opens in new tab)<\/span><\/a><\/b><\/p>\n<p><b>Moles <\/b>is a lightweight framework for<b> test stubs and detours in .NET<\/b> that is based on delegates. Moles may be used to detour any .NET method, including non-virtual\/static methods in sealed types. <strong>Moles is freely available on Visual Studio Gallery<\/strong> or bundled with <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/project\/pex4fun\/\">Pex<\/a>.<\/p>\n<p><span id=\"3e1da3ce-d824-4b8b-85d8-5daf42b92010\" class=\"ImageBlock fn\"><img decoding=\"async\" id=\"Image3e1da3ce-d824-4b8b-85d8-5daf42b92010\" src=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2016\/02\/stubs-n_downloads.gif\" alt=\"\" \/><\/span><br \/>\n<a href=\"https:\/\/www.microsoft.com\/en-us\/research\/project\/pex-and-moles-isolation-and-white-box-unit-testing-for-net\/\"><strong>Download Moles<\/strong><\/a><strong>! (free)\u00a0<\/strong>Read more <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/project\/pex-and-moles-isolation-and-white-box-unit-testing-for-net\/\">documentation<\/a>\u00a0or\u00a0<a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" href=\"http:\/\/www.facebook.com\/pages\/Pex-and-Moles\/118276281518833\" target=\"_blank\">Follow us\u00a0on Facebook<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>.<\/p>\n<p><strong>Troubleshooting in .NET 4.5<\/strong><\/p>\n<p>If you install the .NET Framework 4.5 on a machine, Moles will encounter issues when trying to compile.<\/p>\n<p>The main issue happens when Moles tries to generate stubs or moles for types that exist only in .NET 4.5. Currently, the only workaround is to use filters in the .moles file to avoid loading those types (and dependent types if needed).<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Moles allows to replace any .NET method with a delegate. Moles supports static or non-virtual methods. Moles works well with Pex. The Fakes Framework in Visual Studio\u00a02012 is the next generation of Moles & Stubs. Fakes is different from Moles, however, so moving from Moles to Fakes will require some modifications to your code. The [&hellip;]<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"msr-url-field":"","msr-podcast-episode":"","msrModifiedDate":"","msrModifiedDateEnabled":false,"ep_exclude_from_search":false,"_classifai_error":"","footnotes":""},"research-area":[13560],"msr-locale":[268875],"msr-impact-theme":[],"msr-pillar":[],"class_list":["post-170392","msr-project","type-msr-project","status-publish","hentry","msr-research-area-programming-languages-software-engineering","msr-locale-en_us","msr-archive-status-active"],"msr_project_start":"2010-01-25","related-publications":[159552],"related-downloads":[],"related-videos":[],"related-groups":[],"related-events":[],"related-opportunities":[],"related-posts":[],"related-articles":[],"tab-content":[],"slides":[],"related-researchers":[{"type":"user_nicename","value":"jhalleux","display_name":"Peli de Halleux","author_link":"<a href=\"https:\/\/www.microsoft.com\/en-us\/research\/people\/jhalleux\/\" aria-label=\"Visit the profile page for Peli de Halleux\">Peli de Halleux<\/a>","is_active":false,"user_id":32253,"last_first":"de Halleux, Peli","people_section":0,"alias":"jhalleux"}],"msr_research_lab":[199565],"msr_impact_theme":[],"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/170392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-project"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/types\/msr-project"}],"version-history":[{"count":2,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/170392\/revisions"}],"predecessor-version":[{"id":387923,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/170392\/revisions\/387923"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/media?parent=170392"}],"wp:term":[{"taxonomy":"msr-research-area","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/research-area?post=170392"},{"taxonomy":"msr-locale","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-locale?post=170392"},{"taxonomy":"msr-impact-theme","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-impact-theme?post=170392"},{"taxonomy":"msr-pillar","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-pillar?post=170392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}