sgtholotoaster / automoqslim Goto Github PK
View Code? Open in Web Editor NEWSimple "auto-mocking" container inspired by AutoMoq with less dependencies and compatible with .NET Core
License: MIT License
Simple "auto-mocking" container inspired by AutoMoq with less dependencies and compatible with .NET Core
License: MIT License
An exception is thrown when trying to create an instance which has a dependency set to null:
var mocker = new AutoMoqer();
mocker.SetInstance<SomeDependency>(null);
mocker.Create<SomeClassWithSomeDependency>(); // here the exception is thrown
Exception details:
Message:
Castle.DynamicProxy.InvalidProxyConstructorArgumentsException : Can not instantiate proxy of class: ZTool.Data.DataContext.
Could not find a parameterless constructor.
Stack Trace:
ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)
ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
CastleProxyFactory.CreateProxy(Type mockType, IInterceptor interceptor, Type[] interfaces, Object[] arguments) line 62
Mock`1.InitializeInstance() line 311
Mock`1.OnGetObject() line 325
Mock.get_Object() line 179
AutoMoqer.<GetParameters>b__9_0(ParameterInfo p)
SelectArrayIterator`2.ToArray()
Enumerable.ToArray[TSource](IEnumerable`1 source)
AutoMoqer.GetParameters(ConstructorInfo constructor)
AutoMoqer.Create(Type type)
AutoMoqer.Create[T]()
Create<T>()
needs to accept additional parameters that will be used as dependencies for the instantiated class. If Mocker already has an implementation for the passed type, the priority should be given to the implementation passed as a parameter
Happens when you try to create an instance that has a non-abstract dependency not registered in the container
The exception is thrown when trying to create a mock for an abstract class
For example:
public abstract class AbstractClass { ... }
public void Main()
{
var mocker = new AutoMocker();
mocker.GetMock<AbstractClass>(); // the exception is thrown here
}
More info about the exception:
Message:
System.ArgumentException : Can only add interfaces to the mock.
Stack Trace:
Mock`1.As[TInterface]() line 384
AutoMoqer.GetMock[T]()
--- End of stack trace from previous location ---
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.