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
0
votes
1 answer

Moles to mock an indexed property

I am looking for a way to 'detour' a single item in a configuration file with Moles. I can do this: NameValueCollection appsettings = new NameValueCollection(); appSettings.Add("MyKey", "MyValue"); …
0
votes
1 answer

Get Data from App.Config is not working in VS 2008 Framework 3.5

when I'm using Moles in my Unittest it is not possible to get value from the of the appconfig by using the configurationManager. I know this a known issue but I'm wondering if can find good workaround (some trick) to resolve this problem apart…
0
votes
1 answer

Cant find Moles after installation

I've installed Pex & moles and was trying to follow the tutorial but couldnt add a new items --> moles to the test project for some reason cant find the file type there i've tried to reinstall it few times unsuccessfully... what can i do ? thanks…
danfromisrael
  • 2,982
  • 3
  • 30
  • 40
0
votes
2 answers

Moling a type, keeping the original behaviour of a specific method

I'm using Microsoft Moles and am curious on the following topic: Is there any way to set the behaviour of a type (eg. to unimplemented) but keep the original behaviour of a single specific method? My intention is to completely isolate the method…
0
votes
1 answer

Stub generation failes with obsolete attribute, Pex v0.94.51023.0

I have an interface with a method marked with the obsolete attribute. The attributes error parameter is set to true to throw an exception when used. The problem is this causes the stub to not generate for the whole class. When I alter the value to…
Jeremy
  • 1
0
votes
1 answer

Why doesn't framework detour?

I am unit testing code that depends on iTextSharp open source Pdf library. One of the classes inTextSharp is PdfReader with one of the constructors that accepts byte array. I simplified the problem to the following: [TestMethod] …
StanB
  • 1
  • 1
0
votes
2 answers

Using Pex and Moles for kind of non-PUT testing

I want to test some code that isn't written with regards to TDD or any other form of automated testing, using .NET 4. The integrated Unit Testing in VS2010 isn't enough for my goals, so I've looked at Pex & Moles. What I have is a code that is used…
nnevod
  • 61
  • 2
  • 6
0
votes
1 answer

Does Moles work with nUnit?

I have just see the Moles mocking framework from Microsoft Research, before I spend any time looking at it, I would like to know if it will work with nUnit, or do I have to use msTest?
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
0
votes
1 answer

Multiple Moles redirection not working from ClassInitialize

I have multiple test methods that depend on the same Mole redirection, and in order to prevent duplication, I've placed the redirection code in my ClassInit Method: [ClassInitialize] public static void ClassInit(TestContext context) { …
robertz
  • 758
  • 6
  • 11
0
votes
2 answers

Issues debugging Moles

I’m using visual studio 2008 and moles version 0.93. Everything works well except when I try to debug any test that uses a Moled type. The test skips all my breakpoints. And I get the following message in the output window: Unable to attach. Check…
dalcantara
  • 1,613
  • 2
  • 21
  • 35
0
votes
1 answer

Pex reuses values

I am using Pex to generate test cases. I have a function that looks similar to the one below: public void function(List list, List> listOfLists){ // do something with the lists (add values, remove them, ...) } However, I…
stklik
  • 834
  • 1
  • 8
  • 19
0
votes
1 answer

First Moles test - redirection not happening

Here's the code. GetParentPath is called as per normal! [TestMethod] [HostType("Moles")] public void GetParentPath_slashOnEnd_returns() { var sapi = new MPhotobucketApi(); sapi.GetParentPathString = s => s; …
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
0
votes
1 answer

Failing in generating moles files for an assembly

I have been looking at Moles for testing my entity framework generated classes and followed the steps outlined in the video and also the tutorial help documents however I am failing at the first step. I get the following error when adding a new…
aqwert
  • 10,559
  • 2
  • 41
  • 61
0
votes
1 answer

My build passes locally, but fails on TFS showing an error about missing moles

I'm working on unit tests for a certain namespace, let's call it BusinessLayer.Main. Having checked in my latest changeset, I saw it fail on the TFS build despite passing on my machine. The error it shows is "The type or namespace name 'MClassX'…
0
votes
1 answer

Microsoft Moles Directory Exists throws MoleNotInstrumentedException

I'm using Microsoft Moles in Visual Studio Ultimate 2010 and trying to mole the Directory.Exists method. I have the mscorlib.moles file in my assembly and the following header lines but I still get a MoleNotInstrumentedException when trying to run…
Josh DeLong
  • 475
  • 6
  • 24