c# - unit testing to validate a password -


can provide sample code unit test validates users password?

            //set test crate user              asamembershipprovider prov = this.getmembershipprovider();             //call user             membershipcreatestatus status;             membershipuser user = prov.createuser("testuserx", "12345", "test.userx@abc.com", "", "", true, null, out status);             user = prov.getuser("testuserx", false);                //todo asserts             assert.areequal(status, membershipcreatestatus.success);             assert.areequal(user.username, "testuserx");             assert.areequal(user.email, "test.userx@abc.com");             //assert.areequal(password, "12345"); 

if want assert password correct, instead assert able authenticate, rather testing password directly. testing provider's functionality bit redundant.

 assert.areequal(status, membershipcreatestatus.success);   var isauthenticated = membership.validateuser(user.username, "12345");   assert.istrue(isauthenticated);  assert.areequal(user.username, "testuserx");  assert.areequal(user.email, "test.userx@abc.com"); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -