Questions tagged [machine.fakes]

Machine.Fakes attempts to simplify the usage of such fake frameworks on top of MSpec by helping to reduce a lot of the typical fake framework related clutter code in specifications.

From the project's github:
Machine.Fakes is a little framework built on top of Machine.Specifications that can best be described as an extended integration layer between Machine.Specifications and different mock/fake/substitute/"whatever you call them now" frameworks. At the moment of writing I prefer the term "fake". (What a surprise judging from the name of this project ;-))

Machine.Fakes attempts to simplify the usage of such fake frameworks on top of MSpec by helping to reduce a lot of the typical fake framework related clutter code in specifications.

If you choose so, Machine.Fakes even helps you to stay mostly independent of a concrete fake framework by providing a little wrapper API and a provider model for fake frameworks.

Many credits for the ideas incorporated in this framework go to Jean Paul Boodhoo (http://blog.jpboodhoo.com/) who introduced me to a completely different way of handling mocks/fakes/etc during his NothingButDotnet bootcamp. Maybe this is a way for me to give something back ...

12 questions
7
votes
1 answer

Using Machine.Fakes and WithSubject how do you tell the framework to use a specific constructor argument value when creating the subject

I would like to tell the Machine.Fakes framework to use a specific value for a constructor argument when creating the subject The subject under test has the following constructor /// /// Initializes a new instance of the
Edward Wilde
  • 25,967
  • 8
  • 55
  • 64
2
votes
3 answers

How do I mock 'out' parameters with Machine.Fakes independently of the mock framework?

I've hit an impasse with Machine.Fakes. I cannot figure out how to mock an out parameter using only Machine.Fakes equipment. Because of a bug in RhinoMocks, I switched our mfakes adapter to FakeItEasy. As far as I can tell, any of the adapters…
Bryan Boettcher
  • 4,412
  • 1
  • 28
  • 49
2
votes
2 answers

How do I mock a Func<> using Machine.Fakes (Moq)?

I'm trying to test some code I've written have run in to issues trying to mock a func using Machine.Fakes (which uses Moq under the hood). See the code below for an example. public class RoutingEngine : IRoutingEngine { private readonly…
Tim Butterfield
  • 565
  • 5
  • 24
2
votes
2 answers

How do I use Machine.Fakes to ensure a constructor does not call a local method?

Given an constructor that is expected to throw an exception: public class MyObject { public MyObject(String name) { if (String.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); this.Initialize(); } protected…
eduncan911
  • 17,165
  • 13
  • 68
  • 104
1
vote
2 answers

Why Machine.Specifications recommends to use unsigned binaries?

On Machine.Specifications github page I can download both signed and unsigned binaries, and unsigned binaries are recommended. In my .net project all assemblies should be signed by a key. This is external requirement. Also I use InternalsVisibleTo…
1
vote
1 answer

Using Machine.Fakes unit testing with RavenDB EmbeddableDocumentStore

I normally mock IDocumentSession in my MSpec with Machine.Fakes, which the RavenDB guys don't like. How do I use the EmbeddableDocumentStore with Machine.Fakes ?
Jason More
  • 6,983
  • 6
  • 43
  • 52
1
vote
1 answer

Why does this Machine.Fakes parameter matching throw an exception?

I'm using Machine.Fakes.NSubstitute and want to "fake" a return value such that if the input parameter matches a specific value it returns the mock object, otherwise it returns null. I tried the following: host.WhenToldTo(h =>…
Ben Foster
  • 34,340
  • 40
  • 176
  • 285
0
votes
3 answers

Machine.Fakes how to test virtual method implementation?

Given I have a controller class as such: public class ResourceController : AuthorizedController { public virtual string Resource() { //do magic } public virtual string ResourceParent() { var url =…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
0
votes
1 answer

How to tell Machine.Fake to satisfy a dependency with a given type

Suppose I have a context that is configured similar to: Establish context = () => { ... IFileProcesser processer = new FileProcesser(); The() .WhenToldTo(x =>…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
0
votes
1 answer

mocking multiple interfaces wirth machine.fakes

how can I obtain the equivalent of Substitute.For, IQueryable, IDbAsyncEnumerable>() with machine.fakes? I tried using var myFake = An>(); myFake.WhenToldTo(m =>…
0
votes
2 answers

Machine.Fakes "WithFakes has not been initialized yet. Are you calling it from a static initializer?" error

After updating Machine.Fakes to version 1.7 from 1.0.1 I am getting a "WithFakes has not been initialized yet. Are you calling it from a static initializer?" error/exception. I am structering my tests like this: [TestFixture] public class…
Oksen
  • 15
  • 2
0
votes
1 answer

How to use Machine.Fakes.Moq to verify that a method was called?

I am using Machine.Fakes.Moq and I want to verify that a method of an interface was called. What would be the right way to verify it. I want to verify that the method was called with a parameter of a specific type lets say string. Can anyone please…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47