在此测试方法中,我需要比较 user3 的字符串,同时忽略区分大小写。我在想我应该使用 CultureInfo.InvariantCulture 来忽略Case。这是实现这一目标的最佳方法,还是有更好的方法?
//set test to get user
AsaMembershipProvider prov = this.GetMembershipProvider();
//call get users
MembershipUser user1 = prov.GetUser("test.user", false);
//ask for the username with deliberate case differences
MembershipUser user2 = prov.GetUser("TeSt.UsEr", false);
//getting a user with Upper and lower case in the username.
MembershipUser user3 = prov.GetUser("Test.User", false);
//prove that you still get the user,
Assert.AreNotEqual(null, user1);
Assert.AreNotEqual(null, user2);
//test by using the “.ToLower()” function on the resulting string.
Assert.AreEqual(user1.UserName.ToLower(), user2.UserName.ToLower());
Assert.AreEqual(user1.UserName, "test.user");
Assert.AreEqual(user3.UserName, "test.user");