public void TestComposeUrl() { TeaRequest teaRequest = new TeaRequest(); var url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://", url); teaRequest.Headers["host"] = "fake.domain.com"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com", url); teaRequest.Port = 8080; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080", url); teaRequest.Pathname = "/index.html"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html", url); teaRequest.Query["foo"] = ""; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?foo=", url); teaRequest.Query["foo"] = "bar"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?foo=bar", url); teaRequest.Pathname = "/index.html?a=b"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?a=b&foo=bar", url); teaRequest.Pathname = "/index.html?a=b&"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?a=b&foo=bar", url); teaRequest.Query["fake"] = null; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?a=b&foo=bar", url); teaRequest.Query["fake"] = "val*"; url = TeaCore.ComposeUrl(teaRequest); Assert.Equal("http://fake.domain.com:8080/index.html?a=b&foo=bar&fake=val%2A", url); }