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);
                }
            }
        }
        public static void TestGetRolesAsync()
        {
            using (var client = new CloudFlareClient(Credentials.Credentials.Authentication))
            {
                var accounts = client.GetAccountsAsync().Result;
                var roles    = client.GetRolesAsync(accounts.Result.First().Id).Result;

                Assert.NotNull(roles);
                Assert.Empty(roles.Errors);
                Assert.True(roles.Success);
            }
        }
示例#3
0
        public async Task TestGetRolesAsync()
        {
            using var client = new CloudFlareClient(Credentials.Credentials.Authentication);
            var accounts = await client.GetAccountsAsync();

            var roles = await client.GetRolesAsync(accounts.Result.First().Id);

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