Esempio n. 1
0
        public async Task UserManagementService_UpdateUsersAsync_UpdateUserSuccessfull()
        {
            // Arrange: Create 2 users.
            UserRecord user1 = new UserRecord("username", "name", "*****@*****.**", "562222754", "password", Constants.EnabledStatus, Constants.CustomerUserType,
                                              "salt1", Constants.NoValueLong, Constants.NoValueString, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueInt);

            UserRecord user2 = new UserRecord("username1", "name", "*****@*****.**", "562222724", "password", Constants.EnabledStatus, Constants.CustomerUserType,
                                              "salt1", Constants.NoValueLong, Constants.NoValueString, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueLong, Constants.NoValueInt, Constants.NoValueInt);

            await _userManagementService.BulkCreateUsersAsync(new List <UserRecord>() { user1, user2 }).ConfigureAwait(false);

            // Create an update record to change their email and phone numbers.
            UserRecord updateUser1 = new UserRecord("username", email: "*****@*****.**", phoneNumber: "1111111111");
            UserRecord updateUser2 = new UserRecord("username1", email: "*****@*****.**", phoneNumber: "2222222222");

            // Act: Update the created users.
            await _userManagementService.BulkUpdateUsersAsync(new List <UserRecord>() { updateUser1, updateUser2 });

            // Assert: check that the updated users values changed.
            UserObject userObj1 = await _userManagementService.GetUserInfoAsync("username").ConfigureAwait(false);

            UserObject userObj2 = await _userManagementService.GetUserInfoAsync("username1").ConfigureAwait(false);

            bool updateResult = false;

            if (userObj1.Email == "*****@*****.**" && userObj1.PhoneNumber == "1111111111" &&
                userObj2.Email == "*****@*****.**" && userObj2.PhoneNumber == "2222222222")
            {
                updateResult = true;
            }

            Assert.IsTrue(updateResult);


            // Cleanup: delete the created users.
            bool deleteResult = await _userManagementService.BulkDeleteUsersAsync(new List <string>() { "username", "username1" }).ConfigureAwait(false);

            Assert.IsTrue(deleteResult);
        }