public void ResolveTest() { var UserAgent = new UserAgent(); var agent = UserAgent.Resolve(UserAgent, null); Assert.Equal(UserAgent.GetDefaultMessage(), agent); agent = UserAgent.Resolve(null, UserAgent); Assert.Equal(UserAgent.GetDefaultMessage(), agent); UserAgent.AppendUserAgent("test", "2.2.3"); UserAgent.AppendUserAgent("Core", "22"); var resultStr = UserAgent.GetDefaultMessage() + " test/2.2.3"; agent = UserAgent.Resolve(null, UserAgent); Assert.Equal(resultStr, agent); agent = UserAgent.Resolve(UserAgent, null); Assert.Equal(resultStr, agent); agent = UserAgent.Resolve(null, null); Assert.Equal(UserAgent.GetDefaultMessage(), agent); var requestUserAgent = new UserAgent(); requestUserAgent.AppendUserAgent("requestUserAgent", "1.1.1"); requestUserAgent.AppendUserAgent("test", "23"); resultStr = UserAgent.GetDefaultMessage() + " requestUserAgent/1.1.1" + " test/23"; agent = UserAgent.Resolve(requestUserAgent, UserAgent); Assert.Equal(resultStr, agent); }
public void AppendUserAgent(string key, string value) { if (userAgentConfig == null) { userAgentConfig = new UserAgent(); } userAgentConfig.AppendUserAgent(key, value); }
public void AppendUserAgentTest() { var userAgent = new UserAgent(); userAgent.AppendUserAgent("test", "111"); userAgent.AppendUserAgent("test", null); userAgent.AppendUserAgent("test", ""); userAgent.AppendUserAgent("", "2.2.1"); userAgent.AppendUserAgent(null, "2.2.1"); userAgent.AppendUserAgent("Core", "22"); var dict = userAgent.GetSysUserAgentDict(); string result; dict.TryGetValue("test", out result); Assert.Equal("111", result); userAgent.AppendUserAgent("test", "222"); dict.TryGetValue("test", out result); Assert.Equal("222", result); dict.TryGetValue("null", out result); Assert.Null(result); dict.TryGetValue("", out result); Assert.Null(result); dict.TryGetValue("Core", out result); Assert.Null(result); }
public void AppendUserAgent(string key, string value) { userAgentConfig.AppendUserAgent(key, value); }