Exemplo n.º 1
0
        public void GetUserAgentString_FakeMSIETest()
        {
            var mockAssembly = new Mock <Assembly>();

            mockAssembly.Setup(m => m.GetName()).Returns(new AssemblyName("OpenTween"));

            MyCommon.EntryAssembly = mockAssembly.Object;
            MyCommon.FileVersion   = "1.0.0.0";

            Assert.Equal("OpenTween/1.0.0.0 (compatible; MSIE 10.0)", Networking.GetUserAgentString(fakeMSIE: true));
        }
Exemplo n.º 2
0
        public void GetUserAgentString_Test()
        {
            var mockAssembly = new Mock <_Assembly>();

            mockAssembly.Setup(m => m.GetName()).Returns(new AssemblyName("OpenTween"));

            MyCommon.EntryAssembly = mockAssembly.Object;
            MyCommon.FileVersion   = "1.0.0.0";

            Assert.Equal("OpenTween/1.0.0.0", Networking.GetUserAgentString());
        }
Exemplo n.º 3
0
        public void GetUserAgentString_FakeMSIETest()
        {
            var mockAssembly = Substitute.For <_Assembly>();

            mockAssembly.GetName().Returns(new AssemblyName("OpenTween"));

            MyCommon.EntryAssembly = mockAssembly;
            MyCommon.FileVersion   = "1.0.0.0";

            Assert.Equal("OpenTween/1.0.0.0 (compatible; MSIE 10.0)", Networking.GetUserAgentString(fakeMSIE: true));
        }
Exemplo n.º 4
0
        public void GetUserAgentString_Test()
        {
            var mockAssembly = Substitute.For <_Assembly>();

            mockAssembly.GetName().Returns(new AssemblyName("OpenTween"));

            MyCommon.EntryAssembly = mockAssembly;
            MyCommon.FileVersion   = "1.0.0.0";

            Assert.Equal("OpenTween/1.0.0.0", Networking.GetUserAgentString());
        }
Exemplo n.º 5
0
        public static HttpClient CreateHttpClient(HttpMessageHandler handler)
        {
            HttpClient client;

            if (ForceIPv4)
            {
                client = new HttpClient(new ForceIPv4Handler(handler));
            }
            else
            {
                client = new HttpClient(handler);
            }

            client.Timeout = Networking.DefaultTimeout;
            client.DefaultRequestHeaders.Add("User-Agent", Networking.GetUserAgentString());

            return(client);
        }
Exemplo n.º 6
0
        public static HttpClient CreateHttpClient(HttpClientHandler handler)
        {
            if (Networking.Proxy != null)
            {
                handler.UseProxy = true;
                handler.Proxy    = Networking.Proxy;
            }
            else
            {
                handler.UseProxy = false;
            }

            var client = new HttpClient(handler);

            client.Timeout = Networking.DefaultTimeout;
            client.DefaultRequestHeaders.Add("User-Agent", Networking.GetUserAgentString());

            return(client);
        }