serg046 / autofake Goto Github PK
View Code? Open in Web Editor NEWMock any type members including static and non-virtual ones
License: MIT License
Mock any type members including static and non-virtual ones
License: MIT License
Extract all initializations to constructor (SetUp) when possible
Possibly a separate domain is required. If so MarshalByRefObject or some serialization mechanism (binarryformatter, protobuf, serializable, NFX) needs to be implemented
Provide functionality to inject the code to the top of method
Waiting for jbevain/cecil#300
Support two modes:
Please uncomment FakeTests.Execute_Fake_CallbackExecuted as well
Since there is no way to cast type A
from fake's assembly to type A
from the current assembly, some new lambda based methods should be provided. Execute(Action<T> action)
can be introduced as alternative to T Execute()
.
Starting from .NET Core 3 we have assembly unloading supported
Currently only ExpectedCalls(Func<int, bool>) is supported. Please add support for ExpectedCalls(int) too. The thing is that we cannot simply use something like this:
ExpectedCalls(int number) => ExpectedCalls(x => x == number);
Because that code works only on the client side and cannot be placed inside the library as is.
Mock two methods with same name with different return values
Imagine you have the following type:
class SomeType
{
public SomeType(int someProp) => SomeProp = someProp;
public int SomeProp { get; }
public int GetSomeProp(int arg) => SomeProp + arg;
public SomeMethod(int arg) => Console.WriteLine(GetSomeProp(arg));
}
You might want to do something like this:
var fake = new Fake<SomeType>(5);
sut.Replace(f => f.GetSomeProp(3))
.If((SomeType instance, object[] arguments) => instance.SomeProp > 0 && arguments.Single() is uint)
.Return(-1);
sut.Replace(f => f.GetSomeProp(3))
.If((SomeType instance, object[] arguments) => instance.SomeProp == 2 && !(arguments.Single() is uint))
.Return(0);
void SomeMethod(int someVal)
{
return someVal > 0 ? GetVal(someVal) : GetVal(0);
}
In this sample we need always get 1
as actual calls count of GetVal
but now it is 2
.
And if we setup 0
as verifiable argument of GetVal
we need to have successful verification if SomeMethod
is called with someVal <= 0
, otherwise failed verification.
See commented InsertTests.TestClass.Numbers property.
To reproduce, uncomment and use instead of the field
Since 'Execute()' method runs regeneration of the fake type, it should be indicated.
It needs to introduce a new method and force to use it before the second execution of 'Execute'.
If c# 7 is available use pattern-matching of c# 7
Add ability to mock type constructor because it can run some undesirable actions like database access and so on.
Try to create AsyncStateMachineAttribute right in the project with the proper namespace
public TypeReference GetType(string fullName, bool runtimeName)
{
return !runtimeName ? (TypeReference) this.GetType(fullName) : TypeParser.ParseType(this, fullName);
}
We use the same AppDomain by defaut. It doesn't allow to unload the generated lib so that we cannot unload it. Please generate an exception if the fake is configured so that it is impossible to place the lib to a seaprate AppDomain.
It cannot be found by reflection. So it needs to find another way or throw an exception.
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.