ryanwersal / autosplat Goto Github PK
View Code? Open in Web Editor NEWAutomatically Moq dependencies encountered through Splat's Locator.
License: MIT License
Automatically Moq dependencies encountered through Splat's Locator.
License: MIT License
While the auto-mocking is convenient there are times that it isn't always necessarily desirable. Sometimes just having the disposable context handle swapping out the resolver correctly is all the behavior that is needed (to help ensure the resolver is "clean" between runs of test cases).
After updating to Splat 9.0.5, I am now seeing the following exception:
System.MissingMethodException : Method not found: 'Splat.IDependencyResolver Splat.Locator.get_Current()'.
at AutoSplat.AutoMockContext..ctor()
I believe this is due to a change in Splat in how you set the current Locator
. You now have to call SetLocator
: reactiveui/splat@01b2beb
Currently the pattern is:
var myMock = new Mock<IMyInterface>();
myMock.Setup(...).Etc();
Locator.CurrentMutable.RegisterConstant(myMock.Object, typeof(IMyInterface));
and it would be so much more convenient to remove the Splat calls and streamline getting these setup:
var myMock = autoMockContext.RegisterConstant<IMyInterface>();
myMock.Setup(...).Etc();
Additionally it might be ideal to use a callback to configure the mock?
var myMock = autoMockContext.RegisterConstant<IMyInterface>(mock =>
{
mock.Setup(...).Etc();
});
Right now you have to really drill down in the debugger to see what all is loaded into the mock resolver. Having good DebuggerDisplay
attributes would definitely improve this.
This will solve the currently unsolved problem of how to bump versions. Right now it is incredibly adhoc.
Currently swapping out the Locator
, without doing further per-instance work, results in breaking RxApp and Splat's expectations about what services are available and what type they are (since they'll get auto mocked).
It would be ideal to make this as much of a one liner as possible since Splat is used extensively with ReactiveUI so it doesn't seem outlandish to expect it (though offering the option of not requiring ReactiveUI may sink this idea).
Such as that all auto created Mock
objects have their DefaultValue
set and so forth.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.