Пример #1
0
        public async Task GivenICreateTheFollowingUsers(Table table)
        {
            foreach (TableRow tableRow in table.Rows)
            {
                // Get the claims
                Dictionary <String, String> userClaims = null;
                String claims = SpecflowTableHelper.GetStringRowValue(tableRow, "Claims");
                if (string.IsNullOrEmpty(claims) == false)
                {
                    userClaims = new Dictionary <String, String>();
                    String[] claimList = claims.Split(",");
                    foreach (String claim in claimList)
                    {
                        // Split into claim name and value
                        String[] c = claim.Split(":");
                        userClaims.Add(c[0], c[1]);
                    }
                }

                String roles = SpecflowTableHelper.GetStringRowValue(tableRow, "Roles");
                roles = roles.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"));

                CreateUserRequest createUserRequest = new CreateUserRequest
                {
                    EmailAddress = SpecflowTableHelper.GetStringRowValue(tableRow, "Email Address").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")),
                    FamilyName   = SpecflowTableHelper.GetStringRowValue(tableRow, "Family Name"),
                    GivenName    = SpecflowTableHelper.GetStringRowValue(tableRow, "Given Name"),
                    PhoneNumber  = SpecflowTableHelper.GetStringRowValue(tableRow, "Phone Number"),
                    MiddleName   = SpecflowTableHelper.GetStringRowValue(tableRow, "Middle name"),
                    Claims       = userClaims,
                    Roles        = string.IsNullOrEmpty(roles) ? null : roles.Split(",").ToList(),
                    Password     = SpecflowTableHelper.GetStringRowValue(tableRow, "Password")
                };
                CreateUserResponse createUserResponse = await this.CreateUser(createUserRequest, CancellationToken.None).ConfigureAwait(false);

                createUserResponse.ShouldNotBeNull();
                createUserResponse.UserId.ShouldNotBe(Guid.Empty);

                this.TestingContext.Users.Add(createUserRequest.EmailAddress, createUserResponse.UserId);
            }
        }