Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultValue.Mock lazy initialization #1149

Closed
informatorius opened this issue Mar 23, 2021 · 2 comments
Closed

DefaultValue.Mock lazy initialization #1149

informatorius opened this issue Mar 23, 2021 · 2 comments

Comments

@informatorius
Copy link
Contributor

informatorius commented Mar 23, 2021

When I setup a deep mock which setup all interface methods and properties with default values
var mock = new Mock<Interface>{DefaultValue=DefaultValue.Mock};

then it takes more time than only setup a simple mock without all methods or properties
var mock = new Mock<Interface>();

Would it be possible to make deep mock setup faster in moq when it only initializes methods and properties when they are reallly called? A lazy initialization for deep mocks?

@stakx
Copy link
Contributor

stakx commented Mar 23, 2021

There should be no difference in performance between new Mock<T> and new Mock<T> { ... }, the assignments are neglibigle from a performance point of view. You're talking about code ("setting up a deep mock") that you're not showing here so it's hard to tell what the problem is.

@stakx
Copy link
Contributor

stakx commented Apr 3, 2021

Closing due to inactivity.

@stakx stakx closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants