public void Fetch1()
        {
            // When Success
            var mock = new Mock <ECSMetadataServiceCredentialsFetcher>()
            {
                CallBase = true
            };

            HttpResponse response = new HttpResponse();

            byte[] content = Encoding.GetEncoding("UTF-8").GetBytes("{\"Code\":\"Success\",\"Message\":\"ThisIsMessage\",\"RequestId\":\"ThisIsRequestId\",\"AccessKeyId\":\"MockAccessKeyId\",\"AccessKeySecret\":\"\",\"SecurityToken\":\"\",\"Expiration\":\"" + DateTimeMock.getNowDateTimeString() + "\"}");
            response.ContentType = FormatType.JSON;
            response.Content     = content;
            response.Status      = 200;

            mock.Setup(foo => foo.GetResponse(
                           It.IsAny <HttpRequest>()
                           )).Returns(response);

            ECSMetadataServiceCredentialsFetcher instance = mock.Object;

            EcsRamRoleCredential credentials = instance.Fetch();;

            Assert.Equal("MockAccessKeyId", credentials.GetAccessKeyId());
        }
        public void TestEcsRamRoleCredential()
        {
            Mock <IAlibabaCloudCredentialsProvider> mockProvider = new Mock <IAlibabaCloudCredentialsProvider>();

            mockProvider.Setup(p => p.GetCredentials()).Returns(new EcsRamRoleCredential("accessKeyId", "accessKeySecret", "securityToken", 64090527132000L, null));
            EcsRamRoleCredential ecsRamRoleCredential = new EcsRamRoleCredential("accessKeyId", "accessKeySecret", "securityToken", 64090527132000L, mockProvider.Object);

            Assert.Equal("accessKeyId", ecsRamRoleCredential.GetAccessKeyId());
            Assert.Equal("accessKeySecret", ecsRamRoleCredential.GetAccessKeySecret());
            Assert.Equal("securityToken", ecsRamRoleCredential.GetSecurityToken());
            Assert.Equal(64090527132000L, ecsRamRoleCredential.GetExpiration());
            Assert.Equal(AuthConstant.EcsRamRole, ecsRamRoleCredential.GetCredentialType());
            Assert.NotNull(ecsRamRoleCredential.GetNewCredential <EcsRamRoleCredential>());
        }