public void DescribeEndpoint4() { var mock = new Mock <DescribeEndpointServiceImpl>(); int status = 500; HttpResponse response = new HttpResponse(); byte[] content = Encoding.GetEncoding("UTF-8").GetBytes("{\"Code\":\"ServiceError\",\"Message\":\"ThisIsMessage\",\"RequestId\":\"ThisIsRequestId\",\"AccessKeyId\":\"MockAccessKeyId\",\"AccessKeySecret\":\"\",\"SecurityToken\":\"\",\"Expiration\":\"" + DateTimeMock.getNowDateTimeString() + "\"}"); response.ContentType = FormatType.JSON; response.Content = content; response.Status = status; response.Encoding = null; mock.Setup(foo => foo.GetResponse( It.IsAny <HttpRequest>() )).Returns(response); DescribeEndpointServiceImpl instance = mock.Object; Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.DescribeEndpoint( "regionId", "serviceCode", "endpointType", credential, locationConfig ); Assert.Null(result); }
public void DescribeEndpoint5() { var mock = new Mock <DescribeEndpointServiceImpl>(); int status = 200; string jsonContent = "{\"RequestId\":\"RequestId\",\"Endpoints\":{\"Endpoint\":[{\"Id\":\"Id\",\"Endpoint\":\"Endpoint\",\"ServiceCode\":\"ServiceCode\"},{\"Id\":\"Id\",\"Endpoint\":\"Endpoint\",\"ServiceCode\":\"ServiceCode\",\"Type\":\"endpointType\"}]}}"; HttpResponse response = new HttpResponse(); byte[] content = Encoding.GetEncoding("UTF-8").GetBytes(jsonContent); response.ContentType = FormatType.JSON; response.Content = content; response.Status = status; response.Encoding = null; mock.Setup(foo => foo.GetResponse( It.IsAny <HttpRequest>() )).Returns(response); DescribeEndpointServiceImpl instance = mock.Object; Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); var result = instance.DescribeEndpoint( "regionId", "serviceCode", "endpointType", credential, locationConfig ); Assert.NotNull(result); Assert.Equal("Endpoint", result.Endpoint); Assert.Equal("RequestId", result.RequestId); }
public void DescribeEndpoint2() { DescribeEndpointServiceImpl instance = new DescribeEndpointServiceImpl(); Credential credential = new Credential(); LocationConfig locationConfig = new LocationConfig(); // When endpointType is null or empty var result = instance.DescribeEndpoint( "regionId", "serviceCode", null, credential, locationConfig ); Assert.Null(result); }
public void DescribeEndpoint1() { var instance = new DescribeEndpointServiceImpl(); var credential = new Credential(); var locationConfig = new LocationConfig(); // When serviceCode is null or empty var result = instance.DescribeEndpoint( "regionId", null, "endpointType", credential, locationConfig ); Assert.Null(result); }