Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual methods for CognitoUser #49

Merged
merged 1 commit into from
Mar 22, 2021
Merged

Virtual methods for CognitoUser #49

merged 1 commit into from
Mar 22, 2021

Conversation

WajahatAliAbid
Copy link
Contributor

*Issue #, if available:
aws/aws-aspnet-cognito-identity-provider#151
Description of changes:
Mock testing CognitoUser using Moq fails because it needs virtual methods to create a proxy with [1].
image
Currently the workaround is to write a subclass to wrap around the CognitoUser class as follows

public class CustomCognitoUser : CognitoUser
    {
        public CustomCognitoUser(string userID, string clientID, CognitoUserPool pool, IAmazonCognitoIdentityProvider provider, string? clientSecret = null, string? status = null, string? username = null, Dictionary<string, string>? attributes = null) : base(userID, clientID, pool, provider, clientSecret, status, username, attributes)
        {
        }
        public virtual new Task<AuthFlowResponse> StartWithAdminNoSrpAuthAsync(InitiateAdminNoSrpAuthRequest adminAuthRequest)
        {
            return base.StartWithAdminNoSrpAuthAsync(adminAuthRequest);
        }
    }

This PR makes the methods of CognitoUser virtual so we can write mock test cases for CognitoUser class.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@normj normj merged commit 5e75d54 into aws:master Mar 22, 2021
@normj
Copy link
Member

normj commented Mar 22, 2021

This PR is merged as part of version 2.1.0 that went out today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants