Skip to content

Commit

Permalink
domain events api change
Browse files Browse the repository at this point in the history
  • Loading branch information
rofr committed Sep 25, 2014
1 parent 4b8e802 commit cd41453
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/OrigoDB.Core.UnitTests/DomainEventTests.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.CompilerServices;
using NUnit.Framework;

namespace OrigoDB.Core.Test
Expand Down Expand Up @@ -82,7 +82,7 @@ public void CanReRegisterGenericHandler()
}

[Test]
public void CanFilterBasedOnType()
public void CanFilterUsingTypeExpression()
{
var target = new FilteringEventDispatcher();
int calls = 0;
Expand All @@ -91,6 +91,16 @@ public void CanFilterBasedOnType()
Assert.AreEqual(1, calls);
}

[Test]
public void CanFilterUsingTypeParameter()
{
var calls = 0;
var target = new FilteringEventDispatcher();
target.On<Event>(e => calls++);
target.Send(new Event());
Assert.AreEqual(1, calls);
}

[Test]
public void CanFilter()
{
Expand Down
4 changes: 2 additions & 2 deletions src/OrigoDB.Core/Events/FilteringEventDispatcher.cs
Expand Up @@ -44,9 +44,9 @@ public void Subscribe(Action<IEvent> eventHandler, Func<IEvent, bool> selector =
/// <summary>
/// Register or reregister a handler for all events of type T
/// </summary>
public void Subscribe<T>(Action<IEvent> eventHandler) where T : IEvent
public void On<T>(Action<T> eventHandler) where T : IEvent
{
Subscribe(eventHandler, e => e is T);
Subscribe(e => eventHandler.Invoke((T)e), e => e is T);
}


Expand Down
4 changes: 2 additions & 2 deletions src/SharedAssemblyInfo.cs
Expand Up @@ -14,8 +14,8 @@
[assembly: ComVisible(false)]


[assembly: AssemblyVersion("0.17.0")]
[assembly: AssemblyFileVersion("0.17.0")]
[assembly: AssemblyVersion("0.17.1")]
[assembly: AssemblyFileVersion("0.17.1")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OrigoDB.Enterprise")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OrigoDB.Test.MSTest")]
Expand Down

0 comments on commit cd41453

Please sign in to comment.