public virtual void getValues() { IDictionary <string, object> values = ImmutableMap.of("foo", 1, "bar", 2); SingleTypeMarketDataConfig configs = SingleTypeMarketDataConfig.builder().configType(typeof(Integer)).configObjects(values).build(); assertThat(configs.get("foo")).isEqualTo(1); assertThat(configs.get("bar")).isEqualTo(2); assertThrowsIllegalArg(() => configs.get("baz"), "No configuration found with type java.lang.Integer and name baz"); }
public virtual void addValue() { IDictionary <string, object> values = ImmutableMap.of("foo", 1, "bar", 2); SingleTypeMarketDataConfig configs = SingleTypeMarketDataConfig.builder().configType(typeof(Integer)).configObjects(values).build().withConfig("baz", 3); assertThat(configs.get("foo")).isEqualTo(1); assertThat(configs.get("bar")).isEqualTo(2); assertThat(configs.get("baz")).isEqualTo(3); }
/// <summary> /// Returns a set of configuration object for the specified type, creating one and adding it to /// the map if not found. /// </summary> private SingleTypeMarketDataConfig configsForType(Type configType) { SingleTypeMarketDataConfig configs = values[configType]; if (configs != null) { return(configs); } SingleTypeMarketDataConfig newConfigs = SingleTypeMarketDataConfig.builder().configType(configType).build(); values[configType] = newConfigs; return(newConfigs); }
public virtual void addValueWrongType() { assertThrowsIllegalArg(() => SingleTypeMarketDataConfig.builder().configType(typeof(Integer)).build().withConfig("baz", "3"), ".* not of the required type .*"); }