pex-and-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...

C# - What does "\0" equate to?

I am playing with Pex and one of the parameters it passes into my method is "\0". What does that mean? My guess is an empty string ("") based on the content of my method. However, if it is the same then why not just use "" instead of "\0"? Anyone know what it is? ...

Anyone using Moles / Pex in production?

Hi all, I did search the forum and did not find a similar question. I'm looking to make a final decision on our mocking framework of choice moving forward as a best practice - I've decided on Moq... untill I just recently discovered MS has finally created a mocking framework called Moles which seems to work similar to TypeMock via the p...

How to add [assembly: PexLinqPackage] to a test project

I am trying to get Pex to work with linq in my project. I got this explanation on what I need to do: In order for Pex to support Linq, make sure you add a reference to Microsoft.Pex.Linq.dll and add the [assembly: PexLinqPackage] attribute to the test project. I have the reference added. But I have never had to add anything like [a...

Why would I select Moles as my mocking framework?

I've been looking at several Mocking frameworks for ASP.NET and came across Microsoft Moles. This seems to be a part of Microsoft Research team and was wondering If anyone here has selected Moles over other matured Mocking frameworks such as Moq. ...

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. ...

Integrate Pex with MoQ

Can anyone point me to a resource that shows an example of how Pex can be used in conjunction with MoQ? Thanks ...

How to use Moles to stub entity framework stored procedure call?

I'm trying to stub a call to db. The basic idea is for a line of code like this: Person person = (from p in this.Entities.FindPerson("Smith") select p).FirstOrDefault(); to return an object the way I want it without going of to db. FindPerson(string) represents a stored proc (just in case). I tried to overwrite FindPerson but I need ...

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 ...

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...

How to use "Pex and Moles" library with Entity Framework?

This is a tough one because not too many people use Pex & Moles or so I think (even though Pex is a really great product - much better than any other unit testing tool) I have a Data project that has a very simple model with just one entity (DBItem). I've also written a DBRepository within this project, that manipulates this EF model. R...

Parameterized testing tools with automatic code exploration

I've checked and played a bit with Microsoft Pex. It's a very handy tool/library even though it's not as straight forward to write parametrized unit tests with it. But when used correctly it can provide much better test code coverage than writing manual unit tests. Not to mention time spent writing those tests either. And it integrates n...

Why would an assert on a unit test with HostType("Moles") pass when run individually, but fail when run with a group of tests?

I recently got aboard the Pex & Moles bandwagon in order to test some logic with many elements that are static, non-virtual, sealed, etc. Recently, I've begun to see behavior I can't explain from a few of the tests. A couple of the methods for an interface I stubbed out return void, so I set the stubs to delegates that update boolean v...