public void Provider_Creation_Valid() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); Assert.AreEqual(TestConstants.anID, provider.ID, false); Assert.AreEqual(TestConstants.aName, provider.Name, false); }
public void Provider_Creation_Default() { BasicPropertiesProvider provider = new BasicPropertiesProvider(); // check the expected default values checkDefaultProvider(provider); }
public void Provider_IterateProperties() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); BasicProperty propertyAA = new BasicProperty("AA", "AA"); BasicProperty propertyBB = new BasicProperty("BB", "BB"); BasicProperty propertyCC = new BasicProperty("CC", "CC"); List <string> expectedIDs = new List <string>() { "CC", "BB", "AA" }; provider.AddProperty(propertyCC); provider.AddProperty(propertyBB); provider.AddProperty(propertyAA); List <string> actualIds = new List <string>(); foreach (IProperty property in provider.Properties) { actualIds.Add(property.Definition.ID); } Assert.AreEqual(expectedIDs.Count, actualIds.Count); for (int i = 0; i < expectedIDs.Count; i++) { Assert.AreEqual(expectedIDs[i], actualIds[i]); } }
public void Provider_Name_Set() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); provider.Name = TestConstants.newName; Assert.AreEqual(TestConstants.newName, provider.Name, false); }
public void Provider_ID_Set() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); provider.ID = TestConstants.newID; Assert.AreEqual(TestConstants.newID, provider.ID, false); }
public void Provider_AddProperty() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); provider.AddProperty(aProperty); TestUtilities.checkForSingleItem(provider.Properties, aProperty, "Properties"); }
public void Provider_RemoveProperty_ByID() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); provider.AddProperty(aProperty); provider.RemoveProperty(TestConstants.anID); TestUtilities.checkEmpty(provider.Properties, "Properties"); }
public void Should_Be_Able_To_Get_Type_Property_For_Basic_Type() { /* Setup */ var provider = new BasicPropertiesProvider(new RawRabbitConfiguration()); /* Test */ var type = provider.GetProperties <First>().Headers[PropertyHeaders.MessageType]; /* Assert */ Assert.Equal(expected: "RawRabbit.Tests.Common.First, RawRabbit.Tests", actual: type); }
public void Should_Be_Able_To_Get_Type_Property_For_Type_With_Generic_Type_Arguments() { /* Setup */ var provider = new BasicPropertiesProvider(new RawRabbitConfiguration()); /* Test */ var type = provider.GetProperties <Generic <First, Second> >().Headers[PropertyHeaders.MessageType]; /* Assert */ Assert.Equal(expected: "RawRabbit.Tests.Common.Generic`2[[RawRabbit.Tests.Common.First, RawRabbit.Tests],[RawRabbit.Tests.Common.Second, RawRabbit.Tests]], RawRabbit.Tests", actual: type); }
public void Provider_Creation_Invalid_WhitespaceID() { BasicPropertiesProvider provider = null; ArgumentException expectedException = null; try { provider = new BasicPropertiesProvider(TestConstants.whitespaceOnly, TestConstants.aName); } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propID, TestConstants.paramID); Assert.IsNull(provider, "No provider should be created."); }
public void Provider_Creation_Invalid_NullName() { BasicPropertiesProvider provider = null; ArgumentException expectedException = null; try { provider = new BasicPropertiesProvider(TestConstants.anID, null); } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propName, TestConstants.paramName); Assert.IsNull(provider, "No provider should be created."); }
public void Provider_RemoveProperty_NonexistentID() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); KeyNotFoundException expectedException = null; try { provider.RemoveProperty(TestConstants.anID); } catch (KeyNotFoundException e) { expectedException = e; } Assert.IsNotNull(expectedException, "KeyNotFoundException not thrown"); TestUtilities.checkEmpty(provider.Properties, "Properties"); }
public void Provider_ID_SetEmpty() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); ArgumentException expectedException = null; try { provider.ID = string.Empty; } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propID, TestConstants.paramID); Assert.AreEqual(TestConstants.anID, provider.ID, false, "The ID should not change."); }
public void Provider_RemoveProperty_NullID() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); ArgumentNullException expectedException = null; try { provider.RemoveProperty((string)null); } catch (ArgumentNullException e) { expectedException = e; } TestUtilities.checkException(expectedException); TestUtilities.checkEmpty(provider.Properties, "Properties"); }
public void Provider_RemoveProperty_NullProperty() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); ArgumentNullException expectedException = null; try { provider.RemoveProperty((IProperty)null); } catch (ArgumentNullException e) { expectedException = e; } Assert.IsNotNull(expectedException, "ArgumentNullException not thrown"); TestUtilities.checkEmpty(provider.Properties, "Properties"); }
public void Provider_Name_SetWhitespace() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); ArgumentException expectedException = null; try { provider.Name = TestConstants.whitespaceOnly; } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propName, TestConstants.paramName); Assert.AreEqual(TestConstants.aName, provider.Name, false, "The Name should not change."); }
public void Provider_AddProperty_Null() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); ArgumentNullException expectedException = null; try { provider.AddProperty(null); } catch (ArgumentNullException e) { expectedException = e; } TestUtilities.checkException(expectedException, TestConstants.propProperty, TestConstants.paramProperty); TestUtilities.checkEmpty(provider.Properties, "Properties"); }
public void Provider_AddProperty_Duplicate() { BasicPropertiesProvider provider = new BasicPropertiesProvider(TestConstants.anID, TestConstants.aName); BasicProperty aProperty = new BasicProperty(TestConstants.anID, TestConstants.aName); ArgumentException expectedException = null; provider.AddProperty(aProperty); try { provider.AddProperty(aProperty); } catch (ArgumentException e) { expectedException = e; } TestUtilities.checkException(expectedException); TestUtilities.checkForSingleItem(provider.Properties, aProperty, "Properties"); }
/// <summary> /// Creates a default <see cref="IBusClient{TMessageContext}"/> according to config. /// </summary> /// <remarks> /// This component replaces RawRabbit.vNext.BusClientFactory in order to avoid heavy dependency "pollution", but at /// the cost of inflexible, hard-wired setup. /// </remarks> /// <typeparam name="TMessageContext">The type of the context.</typeparam> /// <param name="config">The raw rabbit configuration.</param> /// <returns>The bus client.</returns> public static IBusClient <TMessageContext> CreateDefault <TMessageContext>(RawRabbitConfiguration config) where TMessageContext : MessageContext { var namingConventions = new NamingConventions(); var configurationEvaluator = new ConfigurationEvaluator(config, namingConventions); var connectionFactory = CreateConnectionFactory(config); var channelConfig = new ChannelFactoryConfiguration(); var channelFactory = new ChannelFactory(connectionFactory, config, channelConfig); var consumerFactory = new EventingBasicConsumerFactory(); var topologyProvider = new TopologyProvider(channelFactory); var jsonSerializer = new JsonSerializer(); var serializer = new MessageSerializer(jsonSerializer); IMessageContextProvider <TMessageContext> contextProvider = new MessageContextProvider <TMessageContext>(jsonSerializer); var contextEnhancer = new ContextEnhancer(channelFactory, namingConventions); var propertiesProvider = new BasicPropertiesProvider(config); var errorHandling = new DefaultStrategy( serializer, namingConventions, propertiesProvider, topologyProvider, channelFactory); ISubscriber <TMessageContext> subscriber = new Subscriber <TMessageContext>( channelFactory, consumerFactory, topologyProvider, serializer, contextProvider, contextEnhancer, errorHandling, config); var acknowledger = new NoAckAcknowledger(); var publisher = new Publisher <TMessageContext>( channelFactory, topologyProvider, serializer, contextProvider, acknowledger, propertiesProvider, config); var responder = new Responder <TMessageContext>( channelFactory, topologyProvider, consumerFactory, serializer, contextProvider, contextEnhancer, propertiesProvider, errorHandling, config); var requester = new Requester <TMessageContext>( channelFactory, consumerFactory, serializer, contextProvider, errorHandling, propertiesProvider, topologyProvider, config); var client = new BaseBusClient <TMessageContext>( configurationEvaluator, subscriber, publisher, responder, requester); return(client); }