moles

Can Tests be written in 3.5 MsTest Unit Test assemblies?

老子叫甜甜 提交于 2019-12-07 10:54:46
问题 Hi: I've enjoyed playing around with Pex and Moles...now it's time to use it in earnest to cover an legacy app as much as possible. We've started by converted to .NET 3.5 (the client can't yet host in .NET 4.0) We noticed that we are having trouble with getting Moles to work. Seems to work if the Test Project assembly is a .NET 4.0 -- but when converted the Unit Tests assembly framework back to .NET 3.5 (after installing Visual Studio 2010 SP1 to give that ability) it stops working. Keeps

How use Moles for a constructor?

岁酱吖の 提交于 2019-12-07 01:30:49
问题 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; } public void ModifyPrice(float modifier) { _price = _price * modifier; } I want ModifyPrice to do nothing for a specific value, but I also want to call the constructor that set the price to 10. I tried something like this: var fake = new SProduct() { CallBase = true }; var mole = new MProduct

Has anyone made moles work properly?

℡╲_俬逩灬. 提交于 2019-12-06 11:40:09
I was trying to find a consistent description on how to use moles isolation framework but haven't found much on this topic. So far i did the following: Download moles from here (x86 version). Install it. Here guy describes how to use it with custom library. So i added moles assembly for my own library. After rebuild the assembly appeared in references. Then i tried to add using of .Moles namespace and build the project but it failed with bunch of errors. Example with MDateTime didn't work either. MDateTime just didn't have any method. Considering that was 5th failed attempt to get it work i

Missing Add Moles assembly

你说的曾经没有我的故事 提交于 2019-12-06 08:17:24
I have been trying to install Moles but even though the installation goes through fine, I don't see Add Moles Assembly option when I right-clicked on a dll in References. What am I missing? I installed x64 version (I'm on Windows 7) from here: http://visualstudiogallery.msdn.microsoft.com/22c07bda-ffc9-479a-9766-bfd6ccacabd4/ I'm using Visual Studio 2010 Ultimate. I don't have admin rights on my machine. Could that be a problem? After installation, I went to About Microsoft Visual Studio and do not see any mentions of Pex or Moles on installed products. Does anyone else have the same problem?

Why does Moles keep getting readded to my project?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 04:48:21
问题 I added Moles to a project in VS2010, decided I didn't want to use it and then removed the Moles reference and the .behaviours and .moles assemblies. The problem is that I repeatedly find Moles has been readded to the project with no intervention from me. Is there some kind of setting external to a project that will auto-add it if it's installed? 回答1: Be sure you have done the following: Remove the references to the moles assemblies (e.g. "MyAssembly.Moles") Remove reference: Microsoft.Moles

Moling DataContext with MS Moles?

老子叫甜甜 提交于 2019-12-06 02:05:39
问题 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<MIncmoingMessage>(); MTable<MIncomingMessage> messageTable = new MTable<MIncomingMessage>(); messageTable.Bind(messagesLinqList.AsQueryable()); If I use this code with

how can I use Moles to redirect select from tables via LINQ?

浪子不回头ぞ 提交于 2019-12-05 21:21:41
I have a table called Subscriptions. I'd like to redirect any LINQ select from that table to a Moles lambda so that only 3 rows are returned from that table -- basically I want to bypass the call to the database. So far, the code I have looks like this: // lazy loader is here to handle successive calls to the // same table (otherwise there's an error) // CM is a namespace alias Table<CM.Subscriptions> subsTable = null; MTheDataContext.AllInstances.SubscriptionsGet = (c) => { if (subsTable == null) { subsTable = c.GetTable<CM.Subscriptions>(); subsTable.Attach(new CM.Subscriptions() { SubID = 1

Shims are not generated for .NET methods

本秂侑毒 提交于 2019-12-04 17:47:32
问题 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 trying to shim some of the methods in TcpClient and only stubs are created, which does me no good, since I want to be able to change some of the methods to return my own data rather than depending on a live TcpClient to give me data. I'm open to any

What to put as the Provider for a mocked IQueryable

巧了我就是萌 提交于 2019-12-04 09:25:36
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<User>(); userTable.Bind(new List<User> { UserObjectHelper.TestUser() }); // this is the line that needs help MolesDelegates.Func<IQueryProvider> provider = //Insert provider here! ^ userTable.ProviderSystemLinqIQueryableget = provider | | | what can I put here? -----

Moling DataContext with MS Moles?

こ雲淡風輕ζ 提交于 2019-12-04 05:36:16
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<MIncmoingMessage>(); MTable<MIncomingMessage> messageTable = new MTable<MIncomingMessage>(); messageTable.Bind(messagesLinqList.AsQueryable()); If I use this code with xUnit in my class under test I'll get this exception Microsoft.Moles.Framework.Moles