コード例 #1
0
        public static void TestAddAndDeleteAccountMemberAsync(string emailAddress)
        {
            using var client = new CloudFlareClient(Credentials.Credentials.Authentication);
            var accounts           = client.GetAccountsAsync().Result;
            var roles              = client.GetRolesAsync(accounts.Result.First().Id).Result;
            var addedAccountMember = client.AddAccountMemberAsync(accounts.Result.First().Id, emailAddress, roles.Result).Result;

            Assert.NotNull(addedAccountMember);

            var notAvailable = new List <int>
            {
                429,  // add limit reached
                1004, // Account member already exists for email address
            };

            if (!addedAccountMember.Errors.Any(x => notAvailable.Contains(x.Code)))
            {
                Assert.True(addedAccountMember.Success);
                if (addedAccountMember.Errors != null)
                {
                    Assert.Empty(addedAccountMember.Errors);
                }

                var deletedAccountMember = client.DeleteAccountMemberAsync(accounts.Result.First().Id, addedAccountMember.Result.Id).Result;

                Assert.NotNull(deletedAccountMember);
                Assert.True(deletedAccountMember.Success);
                if (addedAccountMember.Errors != null)
                {
                    Assert.Empty(addedAccountMember.Errors);
                }
            }
        }