示例#1
0
        protected GraphRbacManagementClient GetGraphClient(RestTestFramework.MockContext context)
        {
            var    environment = RestTestFramework.TestEnvironmentFactory.GetTestEnvironment();
            string tenantId    = null;

            if (HttpMockServer.Mode == HttpRecorderMode.Record)
            {
                tenantId   = environment.Tenant;
                UserDomain = environment.UserName.Split(new[] { "@" }, StringSplitOptions.RemoveEmptyEntries).Last();

                HttpMockServer.Variables[TenantIdKey] = tenantId;
                HttpMockServer.Variables[DomainKey]   = UserDomain;
            }
            else if (HttpMockServer.Mode == HttpRecorderMode.Playback)
            {
                if (HttpMockServer.Variables.ContainsKey(TenantIdKey))
                {
                    tenantId = HttpMockServer.Variables[TenantIdKey];
                    AzureRmProfileProvider.Instance.Profile.Context.Tenant.Id = new Guid(tenantId);
                }
                if (HttpMockServer.Variables.ContainsKey(DomainKey))
                {
                    UserDomain = HttpMockServer.Variables[DomainKey];
                    AzureRmProfileProvider.Instance.Profile.Context.Tenant.Domain = UserDomain;
                }
            }

            var client = context.GetGraphServiceClient <GraphRbacManagementClient>(environment);

            client.TenantID = tenantId;
            return(client);
        }