Questions tagged [moles]

Moles - an isolation framework for Microsoft .NET. It allow you to replace any .NET method with a delegate.

Moles is an isolation framework for Microsoft .NET, that allow you to replace any method (including non-virtual/static methods in sealed types) with your own delegate. The moles project was created by the Microsoft Research Pex team.

257 questions
61
votes
1 answer

How to tell Pex not to stub an abstract class that has concrete implementations

I'm trying to use Pex to test some code. I have an abstract class with four concrete implementations. I have created factory methods for each of the four concrete types. I had also created one for the abstract type, except as this nice thread…
Andrew
  • 14,325
  • 4
  • 43
  • 64
22
votes
3 answers

How Moles Isolation framework is implemented?

Moles is an isolation framework created by Microsoft. A cool feature of Moles is that it can "mock" static/non-virtual methods and sealed classes (which is not possible with frameworks like Moq). Below is the quick demonstration of what Moles can…
Buu
  • 49,745
  • 5
  • 67
  • 85
16
votes
2 answers

Shims are not generated for .NET methods

When I began using Microsoft Fakes, I was excited to start shimming some .NET methods. I was lead to believe that I would be able to shim ANY .NET method, static or not: http://msdn.microsoft.com/en-us/library/hh549176.aspx. However, I've been…
David J
  • 263
  • 2
  • 10
12
votes
6 answers

How To Read UnitTest Project's App.Config From Test With HostType("Moles")

I have the folowing tests: [TestClass] public class GeneralTest { [TestMethod] public void VerifyAppDomainHasConfigurationSettings() { string value = ConfigurationManager.AppSettings["TestValue"]; …
Draco Ater
  • 20,820
  • 8
  • 62
  • 86
11
votes
3 answers

Error "The type or namespace xxxx does not exist" when compiling Moles in Visual Studio 2012

I am attempting to compile an existing project (targets .NET4) developed in Visual Studio 2010 and now testing migration to VS2012. When I compile my existing project with moles, I get the following error a lot. The type or namespace name 'Claim'…
7
votes
2 answers

How use Moles for a constructor?

I have a class like this: public class Product : IProduct { static private string _defaultName = "default"; private string _name; private float _price; /// Constructor public Product() { _price = 10.0F; } …
Jeco
  • 1,080
  • 8
  • 11
7
votes
1 answer

How do microsoft fakes' shims actually work internally?

So I am interested in the way that it is implemented. Basically: How can I re-implement the same thing myself? ... which I am not intending to do. Just understand. The fundamental question is: How is it possible to (?) intercept class instantiation…
Robetto
  • 739
  • 7
  • 20
7
votes
2 answers

Moving away from Pex and Moles in VS 2012?

When it comes to testing I've backed into it. I'm now a huge fan, and often do something like TDD. In VS 2010 for design and regressions I've just used MSTEST. This is great - all my projects are open source and connected to my work anyway (physics…
Gordon
  • 3,012
  • 2
  • 26
  • 35
6
votes
1 answer

microsoft moles, dynamically instrument

Moles can be used in two ways: Manually Including [assembly: MoledType(typeof(_type_to_instrument))] Specify [HostType("Moles")] Call Microsoft.Moles.Framework.Moles.MoleRuntime.SetMole(Delegate _stub, object _receiver, MethodInfo…
payo
  • 4,501
  • 1
  • 24
  • 32
6
votes
4 answers

Moles 0.94.51023.0 error on VS 2010 SP1

I'm trying to mole System.ServiceModel v4 in VS 2010 SP1 with Moles 0.94.51023.0 and I keep getting the following errror: The type or namespace name 'IHttpCookieContainerManager' does not exist in the namespace 'ssm::System.ServiceModel.Channels'…
Nick Nieslanik
  • 4,388
  • 23
  • 21
6
votes
3 answers

Syntax Comparison between Moq and Rhino mocks

My company is trying to decide if we are going to standardize on Moq, Rhino Mocks or MS Moles and Stubs. I know Rhino Mocks and Moles and Stubs fairly well. But I am unfamiliar with Moq. How does the syntax work? Does it support Arrange Act…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
6
votes
2 answers

Moling DataContext with MS Moles?

How can I mole the DataContext that I'm using in a class to write messages to a table. I'd like to assert that the table LINQ is writing to has the expected count of messages. Here's what i have so far. var context = new…
devployment
  • 2,121
  • 1
  • 22
  • 33
6
votes
4 answers

Mocking Azure Storage Transactions

I am looking for mocking the azure storage transactions using Moles Mocking framework. Any thoughts/documentation/samples on how to mock the azure storage transactions using Moles or may be any other mocking framework?
Kunal Kapoor
  • 768
  • 5
  • 10
5
votes
2 answers

Isolation framework for testing for Mono

Having read good things about Moles I'd like to add an isolation framework to our set of tools for writing unit tests. Our application runs under Mono as it is deployed on both Linux and Windows and I cannot seem to find a framework that supports…
sebjsmith
  • 71
  • 5
5
votes
1 answer

How to provide a user defined delegate with out parameters in Microsoft Moles

I wanted to bypass an internal method call and hence have mocked it. The mocked method delegate looks like: public Microsoft.Moles.Framework.MolesDelegates.OutOutFunc GetlineStringStringOutStringOut { set; } Now, in my…
Rahul
  • 76,197
  • 13
  • 71
  • 125
1
2 3
17 18