microsoft-fakes

How do I add a fakes assembly in VS 2012 Professional RC?

霸气de小男生 提交于 2019-12-05 08:33:36
问题 According to the two articles below on VS 2012 and Microsoft Fakes Test Framework, I should be able to right click on an assembly in my test project's references and choose "Add Fakes Assembly" to create a new Microsoft Fakes Framework Assembly in Visual Studio 11 / 2012. However I do not find the context menu item in VS 2012 RC Professional where it should be. I may need to reference the Microsoft.QualityTools.Testing.Fakes assembly, but I cannot find it in the add reference search either.

Add Fakes Assembly option missing

荒凉一梦 提交于 2019-12-05 03:29:54
I'm trying to get the Microsoft Fakes up and running in a Unit test project that I've set up in my solution. For some reason the Add Fakes Assembly option is missing which means I can't create mockups of assemblies. And since this is the only alternative to add the Microsoft.QualityTools.Testing.Fakes assembly I can't use the Shim functionality either. I've recently installed Visual Studio 2012 Professional and installed update 3 and this is the first go in Visual Studio 2012 . And I haven't changed any settings. Although I have installed ReSharper , could this be the culprit? Both Visual

Error “The extern alias 'snh' was not specified in a /reference option ” in a C# test project using Microsoft Fakes

我们两清 提交于 2019-12-05 02:43:42
I have a C# test project that uses Microsoft fakes. An external library ( abc.dll ) that the project is referencing was recently updated to .net standard 2.0 . After updating the abc.dll library reference to the latest version, the test project doesn't build any more and also doesn't generate the fake assembly for that library ( dll ). I see the following error in the generated .csproj file. The external alias 'snh' was not specified in a /reference option I looked at the generated . csproj file and the alias snh corresponds to System.Net.Http . The test project is targeting .net 4.6.1 and I'm

Unable to run Unit Tests that uses Microsoft Fakes - Exception in ShimsContext.Create() Method

青春壹個敷衍的年華 提交于 2019-12-04 19:51:56
My problem is very similar to one reported here: UnitTestIsolationException when debugging tests using Fakes However, I am not even able to run the tests. Using the sample code provided here: Isolating Code Under Test with Microsoft Fakes (Getting Started with Shims), I get following exception on running the test below : the offending line is : using (ShimsContext.Create()) Exception on running the test: Test Name: TestMethod1 Test FullName: TestingShimsAndStubs.UnitTest1.TestMethod1 Test Source: c:\poc\TestingShimsAndStubs\TestingShimsAndStubs\UnitTest1.cs : line 12 Test Outcome: Failed Test

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

How to use Microsoft Fakes framework to shim an instance method?

两盒软妹~` 提交于 2019-12-04 12:57:17
I am using Microsoft Fakes framework within VS2012. I use the following code to shim instance methods of my type. using (ShimsContext.Create()) { ShimDateTime.NowGet = () => { return new DateTime(1949, 10, 1); }; DateTime now = DateTime.Now; // shim works for the static property DateTime.Now. Class1 dependency = new Class1(); using (ShimsContext.Create()) { ShimClass1 shim1 = new ShimClass1(); StubClass1 stub1 = new StubClass1(); shim1.method1 = () => { return "shim method1"; }; shim1.IMethod1 = () => { return "shim IMethod1"; }; String s1 = dependency.method1();// shim doesn't work for the

Fakes Broken in Visual Studio 2015

泄露秘密 提交于 2019-12-04 08:42:45
问题 I have Visual Studio 2015 Enterprise and discovered that I cannot compile almost any of our existing 2013 projects. Further investigation reveals that Visual Studio 2015 isn't able to generate fakes for types that were fine in Visual Studio 2013. Consider the following steps to reproduce: Create a unit test project targeting .NET 4.5 Right-click on "System" in the references tab and choose "Add Fakes Assembly" To eliminate the noise for this example, edit the subsequent "System.fakes" file:

Fakes assembly is not generating

纵饮孤独 提交于 2019-12-04 03:12:30
I can't figure out what I need to do to generate Fakes. In my test project I included a reference to the assembly that I want to fake. It added /Fakes/<assembly name>.fakes to my project and it built the project. There were a ton of warnings, but there are 0 errors and the build completed successfully. But it is not adding any reference to the generated .Fakes assembly. Most of the warnings were things like cannot generate stubs or shims for an enum, or some private class is not visible to the fakes assembly. There's really only 1 class in the assembly that I want to Shim, and nothing that I

How to mock/isolate internal classes in VS 2012 with Fakes Framework shims?

巧了我就是萌 提交于 2019-12-04 02:45:33
So, the issue is that I have a bunch of internal classes in my assembly that are used by the class I want to test. Since accessors have been removed from VS2012, I'm fine with using [InternalsVisibleTo] and that works great... except when I try to shimify my internal classes, they are not visible to the Fakes framework. I should also note that the particular class I am dealing with is a static class with static methods, and I don't really want to refactor everything to use interfaces (and using stubs) because of resistance in the organization to that level of refactoring. Is there a way to

Fakes stopped working after installing Visual Studio 2015

為{幸葍}努か 提交于 2019-12-04 02:35:21
I've installed Visual Studio 2015 as a try-out and since then my unit tests that use fakes won't compile anymore, not even on VS 2013. The unit test project targets .net 4.5. Msdn suggest changing the target framework version. The error is gone if I change the targeted framework to 4.6 but I cannot update my project to .net 4.6 as every developer must update at once. Error that I get: The primary reference "mscorlib.4.0.0.0.Fakes" could not be resolved because it was built against the ".NETFramework,Version=4.6 fraemwork. This is a higher version than the currently targeted framework "