public void CheckShowJsonItemName() { var mockAcsRequest = new MockAcsRequest(); // CheckShowJsonItemName 方法会回调true,且无其它逻辑 Assert.True(mockAcsRequest.CheckShowJsonItemName()); }
public void ConcatQueryString() { var mockAcsRequest = new MockAcsRequest(); Dictionary <String, String> tmpDic = null; // When parameters is null var result = MockAcsRequest.ConcatQueryString(tmpDic); Assert.Null(result); // when parameters is empty tmpDic = new Dictionary <String, String> { }; result = MockAcsRequest.ConcatQueryString(tmpDic); Assert.NotNull(result); // 非null 但是为空 Assert.Empty(result); // When parammters is not null tmpDic = new Dictionary <String, String> { { "foo", "bar" }, { "a", "A" }, { "n", null } }; result = MockAcsRequest.ConcatQueryString(tmpDic); Assert.Equal("foo=bar&a=A&n", result); }
public void Instance() { var mockAcsRequest = new MockAcsRequest(); Assert.IsType <MockAcsRequest>(mockAcsRequest); mockAcsRequest.AcceptFormat = FormatType.XML; Assert.Equal(FormatType.XML, mockAcsRequest.AcceptFormat); Assert.Equal(ProtocolType.HTTP, mockAcsRequest.Protocol); }
public void Parameters() { var mockAcsRequest = new MockAcsRequest(); Dictionary <String, String> tmpDic = new Dictionary <String, String> { { "foo", "bar" } }; mockAcsRequest.QueryParameters = tmpDic; mockAcsRequest.DomainParameters = tmpDic; Assert.Equal(tmpDic, mockAcsRequest.DomainParameters); mockAcsRequest.BodyParameters = tmpDic; Assert.Equal(tmpDic, mockAcsRequest.BodyParameters); }
public void SignRequest() { Dictionary <String, String> tmpDic = new Dictionary <String, String> { { "foo", "bar" }, { "a", "A" }, { "n", null } }; var mockAcsRequest = new MockAcsRequest("https://www.alibabacloud.com/"); HmacSHA1Signer signer = new HmacSHA1Signer(); Credential credential = new Credential("accessKeyId", "accessKeySecret", "securityToken"); ProductDomain domain = new ProductDomain(); MockAcsRequest.ConcatQueryString(tmpDic); HttpRequest request = mockAcsRequest.SignRequest(signer, credential, FormatType.JSON, domain); Assert.Equal("Instance by MockAcsRequest", request.Url); }