moles

How To Read UnitTest Project's App.Config From Test With HostType(“Moles”)

狂风中的少年 提交于 2019-12-03 11:15:34
I have the folowing tests: [TestClass] public class GeneralTest { [TestMethod] public void VerifyAppDomainHasConfigurationSettings() { string value = ConfigurationManager.AppSettings["TestValue"]; Assert.IsFalse(String.IsNullOrEmpty(value), "No App.Config found."); } [TestMethod] [HostType("Moles")] public void VerifyAppDomainHasConfigurationSettingsMoles() { string value = ConfigurationManager.AppSettings["TestValue"]; Assert.IsFalse(String.IsNullOrEmpty(value), "No App.Config found."); } } The only difference between them is [HostType("Moles")] . But the first passes and the second fails.

Shims are not generated for .NET methods

耗尽温柔 提交于 2019-12-03 10:37:06
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 suggestions on how to do this if there is another way beyond Microsoft Fakes. EDIT: Adding code to

Am I the only one getting “Assembly Not Available in the Currently Targeted Framework”?

半世苍凉 提交于 2019-12-02 17:59:38
问题 I have had a persistent problem with Visual Studio 2010 and any framework version reporting this error, after adding a test project: "Assembly Not Available in the Currently Targeted Framework" So far, I have had this happen with only two assemblies, and always consistently: System.ServiceProcess System.Configuration.Install The problem is that the project file does not identify a specific framework version for these references, showing version 0.0.0.0 in the properties. I can work around

Am I the only one getting “Assembly Not Available in the Currently Targeted Framework”?

点点圈 提交于 2019-12-02 09:50:43
I have had a persistent problem with Visual Studio 2010 and any framework version reporting this error, after adding a test project: "Assembly Not Available in the Currently Targeted Framework" So far, I have had this happen with only two assemblies, and always consistently: System.ServiceProcess System.Configuration.Install The problem is that the project file does not identify a specific framework version for these references, showing version 0.0.0.0 in the properties. I can work around this by manually altering the project file to include <SpecificVersion>True</SpecificVersion> in the

NCover support with Moles

☆樱花仙子☆ 提交于 2019-12-02 07:11:08
问题 In our project we use NCover to measure our code coverage. If we measure tests which uses Moles the code coverage for those classes are not measured (0%). This has something to do with both Moles and NCover using the .NET profiler. After some searching on the internet I tried the following in command prompt without any result: set COR_PROFILER={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46} moles.runner.exe /pi:Dispatch /r:"C:\Program Files\NCover\NCover.Console.exe" "C:\Program Files\Microsoft Visual

NCover support with Moles

流过昼夜 提交于 2019-12-02 05:28:38
In our project we use NCover to measure our code coverage. If we measure tests which uses Moles the code coverage for those classes are not measured (0%). This has something to do with both Moles and NCover using the .NET profiler. After some searching on the internet I tried the following in command prompt without any result: set COR_PROFILER={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46} moles.runner.exe /pi:Dispatch /r:"C:\Program Files\NCover\NCover.Console.exe" "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /args:/testcontainer:..\Bin\TestLib.dll" The number behind the COR

Using Moles for TDD with HttpWebRequest

感情迁移 提交于 2019-12-02 01:17:46
问题 I am using VS2010 with SP1 (also have VS2012 installed on the same machine). Moles 1.0 The project is using .NET 4 I added moles assembly to system.dll and get the following error on compile Error 46 The type or namespace name 'IReadOnlyList' does not exist in the namespace 'System.Collections.Generic' (are you missing an assembly reference?) [C:\Test\obj\Debug\Moles\s\m.g.csproj] C:\Test\m.g.cs Test IReadOnlyList .NET 4.5 as far as I know. Anyone else got this issue? 回答1: Updated Solution I

Moles and SharePoint Behaviour types

随声附和 提交于 2019-12-01 23:42:11
We are having problems with the following code: BSPSite site = new BSPSite(); BSPWeb web = site.SetRootWeb(); The error is : Could not load file or assembly 'System.Moles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0ae41878053f6703' or one of its dependencies. The system cannot find the file specified. We have tried rebuilding the Behavoir assembly in the source code to .NET 4 but that didn't go through. We are using v0.94. Any help would be appreciates. kaloyan 1) Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies 2 ) Find Microsoft.Moles.VsHost.x86

.NET Moles Stub Fallthrough Behaviour

冷暖自知 提交于 2019-12-01 23:26:25
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 It is explained in the manual at "Partial Stubs". What you want is CallBase, which is a property of Stubs of Moles : var stub = new SMyInstance() {CallBase = true}; or stub.CallBase = true; Hope this help. 来源: https:/

Using Moles for TDD with HttpWebRequest

这一生的挚爱 提交于 2019-12-01 21:45:24
I am using VS2010 with SP1 (also have VS2012 installed on the same machine). Moles 1.0 The project is using .NET 4 I added moles assembly to system.dll and get the following error on compile Error 46 The type or namespace name 'IReadOnlyList' does not exist in the namespace 'System.Collections.Generic' (are you missing an assembly reference?) [C:\Test\obj\Debug\Moles\s\m.g.csproj] C:\Test\m.g.cs Test IReadOnlyList .NET 4.5 as far as I know. Anyone else got this issue? Updated Solution I was able to get Pex to run in VS 2010 with .Net Framework 4.5 installed. Maybe others have explained that