Open Closed

Identity Pro 9.3.2 Unit Test failing #9861


User avatar
0
raif created

Hello, It seems that confirmation support with an empty phone number has been added for the 9.3.2 Identity Pro module.

There is an unit test named Create_PhoneNumberConfirmed_With_Empty_PhoneNumber() has been created, but the [Fact] attribute is missing.

After adding [Fact] attribute and running the test, the Create method in the IdentityUserAppService service is failing.

I'm not sure if the implementation is wrong or the test is wrong. Could you check it?


1 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    The issue you are experiencing is due to a missing [Fact] attribute on the unit test method, which prevents the test from being executed. After adding the [Fact] attribute, the test runs but fails when calling the Create method of IdentityUserAppService with PhoneNumberConfirmed = true and an empty PhoneNumber.

    This behavior is expected: in ABP Identity Pro 9.3.2, confirming a phone number when the phone number is empty is not a valid scenario. The implementation of the Create method should not allow PhoneNumberConfirmed to be set to true if PhoneNumber is empty. The test is likely intended to verify that the system correctly rejects this invalid input.

    Solution:

    • The test should expect an exception (such as an AbpValidationException or BusinessException) when trying to create a user with PhoneNumberConfirmed = true and an empty PhoneNumber.
    • Update the test to assert that the exception is thrown, for example:
    [Fact]
    public async Task Create_PhoneNumberConfirmed_With_Empty_PhoneNumber()
    {
        // Arrange
        var input = new IdentityUserCreateDto
        {
            UserName = Guid.NewGuid().ToString(),
            Email = CreateRandomEmail(),
            PhoneNumber = "",
            PhoneNumberConfirmed = true,
            Password = "123qwE4r*"
        };
    
        // Act & Assert
        await Assert.ThrowsAsync<AbpValidationException>(async () =>
        {
            await _userAppService.CreateAsync(input);
        });
    }
    

    This will ensure the test passes only if the system correctly prevents confirming an empty phone number.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 05, 2025, 09:28