moles

Can Pex (more specifically Moles) be used to create a sealed class?

I am trying to mock my Linq To SQL classes. I have the following code: IQueryable<User> vUser = (from aUser in _ctx.Users where aUser.UserName == userName select aUser); Clearly while doing a unit test _ctx.Users is null. I can mock _ctx (the data context), but Users is a Table<T> and is sealed. So this fails: _c...

What to put as the Provider for a mocked IQueryable

I am working with Moles and mocking a System.Data.Linq.Table. I got it constructing fine, but when I use it, it wants IQueryable.Provider to be mocked (moled) as well. I just want it to use normal Linq To Objects. Any idea what that would be? Here is the syntax I can use: MTable<User> userTable = new System.Data.Linq.Moles.MTable<Us...

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 do: Assert.AreNotEqual(new DateTime(2012, 1, 1), DateTime.Now); // MDateTime is part of ...

Moles without Pex?

Can Moles be used without having to use Pex? Also, Does anyone know when MS Moles will have a Release candidate? I am hesitant of using it in the Production system without knowing which direction it will head. ...

Using Moles to mock user-made classes

I have searched the forums and all over the web and have not really seen a straight answer for this. I have just been introduced to moles and I read that it can mock any .NET class or function call. However, I am wondering if it is possible to use Moles to mock classes that I have created myself. I have used MOQ before and I have read ...

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 moles file item ensuring that the name of the .moles file matches the assembly I have in the ...

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; var api = new PhotobucketApi(); var parentPath = api.GetParentPath("hello/world/")...

can I use the MbUnit gui with Moles tests?

I'd like to set up our unit tests to use Moles -- mostly so we don't write a lot of interfaces in places that don't call for interfaces. Ok, that part is debatable but it is a concern on our team. To that end, we're investigating Moles. Moles is nifty. Pex is nifty. The issue is that if we build a unit test that uses Moles, suddenly we...

Issues debugging Moles

Hi 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 for one of the following. The application you are trying to debug uses a version of ...

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) { MBase.AllInstances.BaseMethod = b => "Mole"; } However, when the test methods...

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 MJustTestingDataContext(); MyMessagewriter writer = new MyMessageWriter(context); var messageList = new List<MIncmoi...

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 Assert (AAA) like Rhino Mocks (I hear they created it, but I am not sure). Does it have stron...

Trying to use Moles with NUnit. Getting "Moles requires tests to be an instrumented process"

I am trying to use moles with NUnit and am getting the following error "Moles requires tests to be an instrumented process". I am also using Visual NUnit within Visual Studio 2008 to get this working. Any help is welcome. ...

Are there free mocking frameworks that can mock methods and classes that are non-virtual, static or sealed?

I know there is TypeMock and JustMock, but both are commercial products and quite expensive. Are there free or open source mocking frameworks that can compete with the two? I am currencly using Moq, but I'm wondering if open source can catch up? Maybe Moles is the answer (http://msdn.microsoft.com/en-us/library/ff798506.aspx), although ...