public void FallBackToDefaultConfigurationGracefully() { var config = new AnalyticsConfig(""); Assert.AreEqual(config.GetCategory("c", "t"), DefaultEventCategory); Assert.True(config.IsEnabled("c", "t")); }
private Uri RequestUri(string eventClass, string eventType) { return(new UriBuilder(_endpoint) { Query = DictionaryToQueryString(new Dictionary <string, string> { { "key", _gcpKey }, { "analytics_environment", CanonicalEnvironment }, { "event_category", _config.GetCategory(eventClass, eventType) }, { "session_id", _sessionId } }) }.Uri); }
public void HandleConfigPrecedenceRulesCorrectly() { var config = new AnalyticsConfig(_configString); // d.e should route to *.* as there is no match Assert.False(config.IsEnabled("d", "e")); Assert.AreEqual(DefaultEventCategory, config.GetCategory("d", "e")); // d.a should route to *.a as there is not a better match Assert.True(config.IsEnabled("d", "a")); Assert.AreEqual("function", config.GetCategory("d", "a")); // b.d should route to b.* as there is not a better match Assert.True(config.IsEnabled("b", "d")); Assert.AreEqual("function-2", config.GetCategory("b", "d")); // b.a should route to b.* as a match on class is preferred on a match on type (i.e. b.* > *.a) Assert.True(config.IsEnabled("b", "a")); Assert.AreEqual("function-2", config.GetCategory("b", "a")); // b.c should route to b.c as it is an exact match Assert.True(config.IsEnabled("b", "c")); Assert.AreEqual("function-3", config.GetCategory("b", "c")); }