microsoft-fakes

Suppressing Microsoft Fakes warnings

China☆狼群 提交于 2019-11-27 23:31:00
问题 I'm using Microsoft Fakes to shim a couple WindowsAzure components for testing. Following the advice in vs 2012: Shims compile, I updated my .fakes file to just generate the shims I actually need: <Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="false"> <Assembly Name="Microsoft.WindowsAzure.Storage" Version="2.1.0.0"/> <StubGeneration> <Clear/> </StubGeneration> <ShimGeneration> <Clear/> <Add FullName="Microsoft.WindowsAzure.Storage.CloudStorageAccount"/> <Add FullName=

vs 2012: Shims compile

[亡魂溺海] 提交于 2019-11-27 16:24:35
问题 I am trying to make a shim in VS 2012 ultimate as it described in MSDN site: [TestClass] public class TestClass1 { [TestMethod] public void TestCurrentYear() { int fixedYear = 2000; using (ShimsContext.Create()) { // Arrange: // Detour DateTime.Now to return a fixed date: System.Fakes.ShimDateTime.NowGet = () => { return new DateTime(fixedYear, 1, 1); }; // Instantiate the component under test: var componentUnderTest = new MyComponent(); // Act: int year = componentUnderTest.GetTheCurrentYear

Mock framework vs MS Fakes frameworks

和自甴很熟 提交于 2019-11-27 05:53:41
A bit confused on the differences of Mock frameworks like NMock vs the VS 2011 Fakes Framework. Going through MSDN, what I understand is that Fakes allow you to mock your dependencies just like RhinoMock or NMock, however the approach is different, Fakes generates code to achive this functionality but Mocks framework does not. So is my understanding correct? Is Fakes just another Mock framework Jim Cooper Your question was about how the MS Fakes framework is different from NMock and it appears the other answers have resolved some of that, but here is some more information regarding how they

How to pass in a mocked HttpClient in a .NET test?

主宰稳场 提交于 2019-11-27 05:12:29
问题 I have a service which uses Microsoft.Net.Http to retrieve some Json data. Great! Of course, I don't want my unit test hitting the actual server (otherwise, that's an integration test). Here's my service ctor (which uses dependency injection...) public Foo(string name, HttpClient httpClient = null) { ... } I'm not sure how I can mock this with ... say .. Moq or FakeItEasy . I want to make sure that when my service calls GetAsync or PostAsync .. then i can fake those calls. Any suggestions how

Mock framework vs MS Fakes frameworks

筅森魡賤 提交于 2019-11-26 11:46:27
问题 A bit confused on the differences of Mock frameworks like NMock vs the VS 2011 Fakes Framework. Going through MSDN, what I understand is that Fakes allow you to mock your dependencies just like RhinoMock or NMock, however the approach is different, Fakes generates code to achive this functionality but Mocks framework does not. So is my understanding correct? Is Fakes just another Mock framework 回答1: Your question was about how the MS Fakes framework is different from NMock and it appears the