hendryluk / cormo

.NET Application Framework based on Spring and Java EE CDI
MIT License
5 stars 4 forks source link

Unit test support #13

Open hendryluk opened 9 years ago

hendryluk commented 9 years ago

Example (with NUnit + NSubstitute) Ref: http://jglue.org/cdi-unit-user-guide/#mocks

public class MyComponent
{
    [Inject] IDbSet<User> _users;
    [Inject] OtherComponent _otherStuff;
    public void DoSomething()
    {
    }
}

[CormoTest]
public class MyTest
{
    [Inject] MyComponent _component;
    [Produces, Mock] IDbSet <User> _users;

    [Test]
    public void Blah()
    {
        _component.DoSomething();
        _users.Received().Add(user);
    }
}
hendryluk commented 9 years ago

ok, perhaps xunit. For initial implementation I'll probably not even try to make it portable (e.g. nunit/xunit, nsubstitute/moq), I'll just pick xunit and nsubstitute. Cdi-unit is portable (junit, testng, mockito, easymock).