Questions tagged [automocking]

Use automocking for questions related to programmatic creation of mocks from source code and metadata.

References

70 questions
1
vote
1 answer

Why are these mocked objects equal, although configured differently?

The following code should mock two objects with different Email properties. But instead I get two objects with the same Email properties. Why? using (var autoMock = AutoMock.GetStrict()) { var contact1 = autoMock.Mock(); …
Bogdan Verbenets
  • 25,686
  • 13
  • 66
  • 119
1
vote
1 answer

Is there any way to get Rhino Mock to automatically generate the "Expect.Calls" at runtime?

Is there any way to get Rhino Mock to automatically generate the "Expect.Calls" at runtime? So if we were to personify Rhino mock, it would say..."According to this setting, I'm going to generate an expect.call for any method I run across that…
Joe Web
  • 128
  • 1
  • 1
  • 7
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
0 answers

Is there a Automocker.CreateInstance equivalent in NSubstitute?

When I need to create an instance of a complex object, such as a large service, with Moq, I can achieve it using the following approach: //Mocks and Setups needed var autoMocker = new AutoMocker(); var service =…
JLauter
  • 11
  • 4
0
votes
0 answers

Rust, defining generic methods in traits

Let me present you a snippet: use serde::{Deserialize, Serialize}; pub trait Transport { fn send(&self, req: ReqT) -> Result> where ReqT: Serialize + Send, OkT: for<'a>…
0
votes
0 answers

How do I unmock jquery globally in Jest after automocking?

I've used jest automock as I'm facing nested namespace issues for my unit testing of a jQuery application. module.exports = { automock: true; } I'm mostly there, used code from Jon G const jQ =…
Adi C
  • 1
  • 2
0
votes
0 answers

`t is not defined` error when passing a generic parameter to createMock function

I'm trying to test my typescript code using Jest and ts-auto-mock package. But when I pass an interface to createMock function using a generic parameter, it raises a weird error on a weird place! For example when I'm running this…
rostamiani
  • 2,859
  • 7
  • 38
  • 74
0
votes
0 answers

How to create Masstransit's Test Harness with Automock?

In order to create the test harness for the SubmitOrderConsumer, I will have to build a ServiceCollection containing all the depdencies of SubmitOrderConsumer. Mock mockNotifier = new Mock(); Mock
Hiep
  • 2,483
  • 1
  • 25
  • 32
0
votes
1 answer

Resolving dependencies via UnityAutoMoqContainer

I have started using the UnityAutoMoqContainer Here is the Link and I have below 2 questions in particularly around container.GetMock() call. I would expect the below Assert to succeed however it throws an exception. private UnityAutoMoqContainer…
Spock
  • 7,009
  • 1
  • 41
  • 60
0
votes
1 answer

How to test a factory provided class is used

I have a section of code that calls a factory, and then uses the returned object. var myServiceObject = factoryService.GetTheObject(myParam); myServiceObject.DoSomeWork(someData, moreData); // returns void I'm writing a test with Automock where I…
M Kenyon II
  • 4,136
  • 4
  • 46
  • 94
0
votes
1 answer

What is the purpose of Autofacs AutoMock

Hi I just started learning how to use an IOC Container. I picked Autofac and was registering services to inject into my MVC controllers. Now I want to do Unit Test. I know that moq is to mock up dependencies that my controller needs. But then what…
RStyle
  • 875
  • 2
  • 10
  • 29
0
votes
0 answers

How to Automock for existing mock object?

In my existing project, I am using xunit. Currently, it's very irritating to mock each instant in service. So I decided to use AutoMock but my project is very vast and I have already done a lot of code and assigned a lot of values. So is this any…
Dhanashri
  • 39
  • 5
0
votes
1 answer

How to find out which setup failed in Assert of `VerifyAll`?

I am writing the unit test for a method. I have properly configured all the setups. While debugging unit test it works and returns values as expected. But in assertion it still throws false. Therefore, I am not able to understand why does VerifyAll…
Karan Desai
  • 3,012
  • 5
  • 32
  • 66
0
votes
1 answer

What are the difference between `Ploeh.AutoFixture` and `AutoFixture`?

What are the difference between Ploeh.AutoFixture and AutoFixture? I have a project where I cannot use using AutoFixture; However, I have to use using Ploeh.AutoFixture What is the difference between these two and what would be pros and…
Md. Alim Ul Karim
  • 2,401
  • 2
  • 27
  • 36