Skip to content

Commit

Permalink
The db subscription storage will no longer return duplicates when sub…
Browse files Browse the repository at this point in the history
…scribing messages with a inheritance chain
  • Loading branch information
andreasohlund committed Aug 7, 2011
1 parent 23e44f6 commit f4d46eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NServiceBus.Unicast.Subscriptions.NHibernate.Tests
public class When_listing_subscribers_for_message_types : InMemoryDBFixture
{
[Test]
public void The_names_of_all_subscibers_should_be_returned()
public void The_names_of_all_subscribers_should_be_returned()
{
var clientEndpoint = Address.Parse("TestEndpoint");

Expand All @@ -19,8 +19,23 @@ public void The_names_of_all_subscibers_should_be_returned()

var subscriptionsForMessageType = storage.GetSubscriberAddressesForMessage(new List<String> { "MessageType1" });

Assert.AreEqual(subscriptionsForMessageType.Count(), 2);
Assert.AreEqual(subscriptionsForMessageType.First(), clientEndpoint);
Assert.AreEqual(2,subscriptionsForMessageType.Count());
Assert.AreEqual(clientEndpoint,subscriptionsForMessageType.First());
}

[Test]
public void Duplicates_should_not_be_generated_for_interface_inheritance_chains()
{
var clientEndpoint = Address.Parse("TestEndpoint");

//ISomeInterface3:ISomeInterface2:ISomeInterface
storage.Subscribe(clientEndpoint, new List<string> { "ISomeInterface" });
storage.Subscribe(clientEndpoint, new List<string> { "ISomeInterface2" });
storage.Subscribe(clientEndpoint, new List<string> { "ISomeInterface3" });

var subscriptionsForMessageType = storage.GetSubscriberAddressesForMessage(new List<String> { "ISomeInterface", "ISomeInterface2", "ISomeInterface3" });

Assert.AreEqual(1,subscriptionsForMessageType.Count());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public IEnumerable<string> GetSubscribersForMessage(IEnumerable<string> messageT
.Add(Restrictions.In("MessageType", messageTypes.ToArray()))
.SetProjection(Projections.Property("SubscriberEndpoint"))
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.List<string>();
.List<string>()
.Distinct();
}

public void Init()
Expand Down

0 comments on commit f4d46eb

Please sign in to comment.