public void SubscribeTwoMessageTypesShouldCreateTwoSubscriptions( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Address client, string messageTypeString1, string messageTypeString2) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString1, "1.0.0.0"), new MessageType(messageTypeString2, "1.0.0.0") }; sut.Subscribe(client, messageTypes); var subscriptions = storage.GetSubscriptions(messageTypes).ToList(); subscriptions.Should().HaveCount(messageTypes.Count); subscriptions.ForEach(s => { s.Clients.Should().HaveCount(1); s.Clients.First().Should().Be(client); }); }
public void SameClientSubscribesTwiceShouldOnlyCreateOneSubscribtion( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, string messageTypeString) { var client = new Address("testqueue.publisher", "localhost"); var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString, "1.0.0.0") }; sut.Subscribe(client, messageTypes); sut.Subscribe(client, messageTypes); var subscriptions = storage.GetSubscriptions(messageTypes).ToList(); subscriptions.Should().HaveCount(messageTypes.Count); var subscription = subscriptions.First(); subscription.MessageType.Should().Be(messageTypes.First()); subscription.Clients.Should().HaveCount(1); subscription.Clients.First().Should().Be(client); }
public void UnsubscribeWhenClientSubscriptionIsTheOnlyOneShouldRemoveOnlyClient( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Address client, string messageTypeString1) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString1, "1.0.0.0"), }; sut.Subscribe(client, messageTypes); storage.GetSubscriptions(messageTypes).Should().HaveCount(1); sut.GetSubscriberAddressesForMessage(messageTypes).Should().HaveCount(1); sut.Unsubscribe(client, messageTypes); storage.GetSubscriptions(messageTypes).Should().HaveCount(1); sut.GetSubscriberAddressesForMessage(messageTypes).Should().HaveCount(0); }
public void UnsubscribeFromAllMessages( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Address client, string messageTypeString1, string messageTypeString2, string messageTypeString3) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString1, "1.0.0.0"), new MessageType(messageTypeString2, "1.0.0.0"), new MessageType(messageTypeString3, "1.0.0.0"), }; sut.Subscribe(client, messageTypes); storage.GetSubscriptions(messageTypes).Should().HaveCount(3); sut.Unsubscribe(client, messageTypes); storage.GetSubscriptions(messageTypes).ToList().ForEach(s => s.Clients.Should().HaveCount(0)); }
public void UnsubscribeWhenThereIsNoSubscriptionShouldNotCreateSubscription( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Address client, string messageTypeString1) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString1, "1.0.0.0"), }; sut.Unsubscribe(client, messageTypes); storage.GetSubscriptions(messageTypes).Should().BeEmpty(); }
public void UnsubscribeFromAllMessages( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Subscriber subscriber, ContextBag context, string messageTypeString1, string messageTypeString2, string messageTypeString3) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString1, "1.0.0.0"), new MessageType(messageTypeString2, "1.0.0.0"), new MessageType(messageTypeString3, "1.0.0.0"), }; messageTypes.ForEach(mt => sut.Subscribe(subscriber, mt, context).Wait()); storage.GetSubscriptions(messageTypes).Result.Should().HaveCount(3); messageTypes.ForEach(mt => sut.Unsubscribe(subscriber, mt, context).Wait()); storage.GetSubscriptions(messageTypes).Result.ToList().ForEach(s => s.Subscribers.Should().HaveCount(0)); }
public void SingleSubscriptionShouldOnlyCreateOneSubscription( MongoSubscriptionPersister storage, MongoDatabaseFactory factory, Address client, string messageTypeString) { var sut = storage as ISubscriptionStorage; var messageTypes = new List <MessageType>() { new MessageType(messageTypeString, "1.0.0.0") }; sut.Subscribe(client, messageTypes); var subscriptions = storage.GetSubscriptions(messageTypes).ToList(); subscriptions.Should().HaveCount(messageTypes.Count); var subscription = subscriptions.First(); subscription.MessageType.Should().Be(messageTypes.First()); subscription.Clients.Should().HaveCount(1); subscription.Clients.First().Should().Be(client); }