Questions tagged [microsoft-fakes]

Microsoft Fakes is an isolation framework for creating delegate-based test stubs and shims in .NET Framework applications.

Microsoft Fakes is an isolation framework for creating delegate-based test stubs and shims in .NET Framework applications. The Fakes framework can be used to shim any .NET method, including non-virtual and static methods in sealed types.

The Fakes framework grew out of the Pex and Moles projects released by Microsoft Research. Microsoft notes that: "The Fakes Framework in Visual Studio 2012 and 2013 and 2015 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. Moles will not be developed further, so we recommend to migrate to Fakes." (source)"

(Aside: The Pex project evolved into the Intellitest feature in Visual Studio 2015.)

See also:

421 questions
0
votes
1 answer

how to use microsoft fakes with a web service proxy?

I'm trying to write some unit tests for an existing order sending routine: this routine extract an order using entity framework, map the data from the ef classes to the routines exposed by the webservice, and send to the web service. I would like…
Luca Morelli
  • 2,530
  • 3
  • 28
  • 45
0
votes
1 answer

Can i use Microsoft Fakes to "shim" .net function calls in a 3rd party executable?

MS Fakes can be used to redirect function calls to stub or shim functions in your vs project which you have the src code to but i was wondering if it can be used for debugging purposes to shim functions in a 3rd party exe? On the description page,…
james123
  • 137
  • 1
  • 5
0
votes
2 answers

Unity + Interception + Fakes = Big Ball of Fire

I am having trouble with making Unity play nice with the new Fakes framework (formerly pex & moles) When I tried to create fakes of the unity interception library, it caused my unit test to run fine when debugging, but breaks with…
Alwyn
  • 8,079
  • 12
  • 59
  • 107
0
votes
1 answer

StubObserver: How to verify if stub method is called with the right paramerter?

i refer to this article from Peter Provost: Visual Studio 2012 Fakes - Part 3 - Observing Stub Behavior The question is if and how can i verify if the method is called with a defined parameter? For example somthing like that: var wasCalled =…
exception
  • 223
  • 1
  • 4
  • 10
0
votes
1 answer

Can I execute my unit test methods with stubs/shims commands in VS 2012 Professional?, those created in VS 2012 ultimate though

I created my unit test methods with stubs/shims in VS 2012 ultimate. Can I execute my test methods with stubs/shims commands in VS 2012 Professional?
Jaish Mathews
  • 766
  • 1
  • 9
  • 25
0
votes
1 answer

VerificationException when instantiating MVC controller during unit testing

I am doing some unit testing with Microsoft Fakes Framework, and everything works fine until I add System.Web.Mvc fake assembly. From that moment any time I try to initialize a controller in a unit test, a VerificationException is thrown. When I…
Huske
  • 9,186
  • 2
  • 36
  • 53
0
votes
1 answer

Trying to pass method group as parameter

Using Microsoft fakes i have the following method signature in my stub object: public void GetAllOf1ExpressionOfFuncOfT0M0Int32Int32(FakesDelegates.Func>, int, int, IList> stub); which is the stub method for…
Ori Price
  • 3,593
  • 2
  • 22
  • 37
0
votes
1 answer

Using Microsoft Fakes with factory instance methods

I got a class that looks like this: public class MyClass { int myNum; private MyClass() {} public static MyClass CreateInstance() { MyClass a = new MyClass(); a.myNum=5; return a; } public bool…
Lironess
  • 823
  • 1
  • 11
  • 19
0
votes
1 answer

How to resolve method name conflict in VS2012 Fakes framework

I am using VS2012 Fakes and MSTEST framework to do unit test. I have a third party dll and I need to fake it. However there is a method (getItemAt(int)) in the dll that seems to conflict with a method that exits in Fakes. The error message I get…
-1
votes
1 answer

Microsoft Fake Assemblies

I'm trying to generate a ShimDirectory (from System.IO.Directory). In the test project references I right click on System and select Add Fakes Assembly. This creates mscorlib.fakes and System.fakes in the Fakes folder. However, the namespace…
Jasper Kent
  • 3,546
  • 15
  • 21
-1
votes
1 answer

Unit testing using Fakes gives IConvertible exception

What I have The interface: public interface IDocDbRepository { Task UpdateDocumentAsync(JObject updatedDocument); } The implementation: public async Task UpdateDocumentAsync(JObject updatedDocument) { if (updatedDocument…
Codehelp
  • 4,157
  • 9
  • 59
  • 96
-1
votes
1 answer

How to isolate (detour) internal constructor with Microsoft Fakes shim?

I found bunch of examples with StreamReader but how to detour internal constructor? I need to create fakes of some public class with internal constructor to be able to test my code isolated. Imagine I have public class ChangesPostProcessor { …
amarax
  • 508
  • 5
  • 14
-1
votes
1 answer

valid use of Shim in a Test Method in VS 2013 for c# code

I have the below test method code : [TestMethod] public void TestWithNotNull() { using (ShimsContext.Create()) { ShimMyConfiguration.Constructor = @this => new ShimMyConfiguration() { return; …
krrishna
  • 2,050
  • 4
  • 47
  • 101
-1
votes
1 answer

ASP.NET MVC Unit test pattern design

Anybody can suggest some good guideline or pattern for design asp.net mvc unit test. I am new to mvc unit test framework design. I have checked Microsoft fake, Moq, Fakeiteasy. But more preferable is Microsoft fake. Can you please suggest any good…
Furqan Misarwala
  • 1,743
  • 6
  • 26
  • 53
-2
votes
2 answers

How can I fake an extension method? (System.Collections.Generic.CollectionExtensions.GetValueOrDefault)

As shown in the image, I want to fake extension method (seen in Specflow's ScenarioContext class) : public bool TryGetValue(string key, out TValue value) I've created fakes for the System.Collection assembly (which contains the IDictionary…
hexcode
  • 393
  • 1
  • 4
  • 13
1 2 3
28
29