moles

Moling System.dll

徘徊边缘 提交于 2020-01-21 08:59:45
问题 I need to unit test a method that is using the System.Net.WebClient in the System.dll . I tried to Mole the System.dll , but when I tried to compile the project to add references to the System.dll mole, I got a bunch of errors like the following: Error 2 'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 251374 33 DGALib.IO.Tests Error 3 'System.Net.Moles

Is there a workaround for setting [HostType(“Moles”)] when dealing with anonymous methods in MSpec?

吃可爱长大的小学妹 提交于 2020-01-15 06:26:25
问题 I'm using Pex and Moles for my low-level unit testing, but I'm also exploring MSpec for business-logic validation, and would like to keep using Moles for consistency. The problem, I think, is that MSPec uses anonymous methods, so there's no way to apply the HostType("Moles") attribute. For example: Because of = () => employeeList = EmployeeManager.GetUsersByRoles(rolesToLoad); It should_return_a_list_of_employees = () => employeeList.ShouldNotBeNull(); I'm mocking the Roles provider called

Cannot use moles to mock the MVC framework

て烟熏妆下的殇ゞ 提交于 2020-01-13 10:19:08
问题 I am trying to generate moles for the System.Web.Mvc DLL version 3, but I get the following error: Moles : info : metadata : loading C:\TFS.as12.Projects\Project X\Main\Source\3rdPartyComponents\MVC3\System.Web.Mvc.dll Moles : info : compilation : output assembly name: System.Web.Mvc.Moles Moles : warning : metadata : failed to load module System.Web.Mvc.dll: Moles : warning : metadata : Inheritance security rules violated by type: 'System.Web.Mvc.CompareAttribute'. Derived types must either

How to assign/opt from multiple delegates for a 'moled' method?

橙三吉。 提交于 2020-01-04 05:24:16
问题 I am currently examining Moles from the outside while I wait for my VS 2010 license, and I wonder whether Moles allows me to: provide the ability to assígn multiple mole delegates for a method being moled, perhaps at a test fixture setup level? switch in runtime in my test case, which of my mole delegates must be invoked for the upcoming call(s) to the moled method being isolated? Any hints? 回答1: Best Answer: It is much easier and makes far more sense to include gating logic in the detour

Is Pex and Moles project still active?

余生颓废 提交于 2020-01-03 18:30:51
问题 They used to release a two new versions a month but since October 2010 they haven't released a new one. I've found this. But the fact they have closed its support forum on MSDN makes me suspect the project is not going forward. We are using it for our current project, but we are thinking to replace it for another framework before it is too late. 回答1: We (the Pex team) has been quite busy working on productizing Moles. This will bring some changes to how things work internally, which has been

Missing Add Moles assembly

本秂侑毒 提交于 2020-01-02 11:45:43
问题 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

Missing Add Moles assembly

妖精的绣舞 提交于 2020-01-02 11:45:35
问题 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

.NET Moles Stub Fallthrough Behaviour

天涯浪子 提交于 2019-12-31 03:23:40
问题 Is it possible in the .NET Moles framework to use the Fallthrough Behavior in Stub Types as we do with Mole Types? I can override the default behavior of a Mole instance by doing: MMyInstance.InstanceBehavior = MoleBehaviors.Fallthrough; However for a Stub Instance i can´t find in the BehavedBehaviors class the corresponding behavior. I'm using version 0.94 Thanks Hugo Pais 回答1: It is explained in the manual at "Partial Stubs". What you want is CallBase, which is a property of Stubs of Moles

Moles adding assembly to wrong project

落花浮王杯 提交于 2019-12-24 10:55:17
问题 I'm trying to get started with Microsoft Moles in order to be able to mock my extension methods, but I'm falling short. I've successfully installed Moles on my workstation, but when I go to my test project (a class library project referencing NUnit, not an MSTest project), navigate down through References, right-click the assembly I want to stub (NHibernate in this case) and click "Add moles assembly...", the NHibernate.moles file shows up in an entirely different project in my solution. It's

Unit testing: how to test methods with a lot of underlying objects and business logic

和自甴很熟 提交于 2019-12-23 18:11:06
问题 I am really new to unit testing, and I can't figure out the proper way to do it for my case, though I spent crazy amount of time on research. My code base is huge (~3 years of work), very coupled unfortunately, hard to test and no unit testing has ever been done on it. So for instance, when trying to test a collection class ProductCollection , more specifically, the bool MoveElementAtIndex(Product productToMove, int newIndex) of it, I am encountering the following problems: first I have to