public void Normalize_Invalid() { Assert.Throws <ArgumentException>(() => "\uFB01".Normalize((NormalizationForm)7)); Assert.Throws <ArgumentException>("strInput", () => "\uFFFE".Normalize()); // Invalid codepoint Assert.Throws <ArgumentException>("strInput", () => "\uD800\uD800".Normalize()); // Invalid surrogate pair Assert.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.Normalize(null)); }
public void IsNormalized_Invalid() { Assert.Throws <ArgumentException>(() => "\uFB01".IsNormalized((NormalizationForm)10)); Assert.Throws <ArgumentException>("value", () => "\uFFFE".IsNormalized()); // Invalid codepoint Assert.Throws <ArgumentException>("value", () => "\uD800\uD800".IsNormalized()); // Invalid surrogate pair Assert.Throws <ArgumentNullException>("value", () => StringNormalizationExtensions.IsNormalized(null)); Assert.Throws <ArgumentNullException>("value", () => ((string)null).IsNormalized()); }
public override void Enable(OptionSet options) { options.Add( "o=|owner=", $"The id of the user to {_verb} {_entityName}s for; by default, shared {_entityName}s are {_verb.TrimEnd('e')}d", o => { OwnerId = StringNormalizationExtensions.Normalize(o); if (OwnerId != null) { IncludeShared = false; } }); }
public void Normalize_Invalid() { Assert.Throws <ArgumentException>(() => "\uFB01".Normalize((NormalizationForm)7)); Assert.Throws <ArgumentException>("strInput", () => "\uFFFE".Normalize()); // Invalid codepoint Assert.Throws <ArgumentException>("strInput", () => "\uD800\uD800".Normalize()); // Invalid surrogate pair Assert.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.Normalize(null)); Exception exception = Record.Exception(() => ((string)null).Normalize()); // On desktop Normalize is not extension method, trying to do ((string)null).Normalize() // will get NullReferenceException, in .Net Core we use extension method which will throw // ArgumentNullException Assert.True((exception is ArgumentNullException) || (exception is NullReferenceException)); }
public void ExceptionsTest() { string fi = "\uFB01"; // "Expected to throw with invalid Normalization" Assert.Throws <ArgumentException>(() => fi.IsNormalized((NormalizationForm)10)); // "Expected to throw with invalid Normalization" Assert.Throws <ArgumentException>(() => fi.Normalize((NormalizationForm)7)); string invalidCodepoint = "\uFFFE"; string invalidSurrogate = "\uD800\uD800"; // "Expected to throw with invalid codepoint" Assert.Throws <ArgumentException>(() => invalidCodepoint.Normalize()); // "Expected to throw with invalid surrogate pair" Assert.Throws <ArgumentException>(() => invalidSurrogate.Normalize()); // "Expected ArgumentNullException when passing null string" Assert.Throws <ArgumentNullException>(() => StringNormalizationExtensions.Normalize(null)); }
public void Normalize_Null() { AssertExtensions.Throws <ArgumentNullException>("strInput", () => StringNormalizationExtensions.Normalize(null)); }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // Customize the ASP.NET Identity model and override the defaults if needed. // For example, you can rename the ASP.NET Identity table names and more. // Add your customizations after calling base.OnModelCreating(builder); builder.Entity <UserModel>(b => { // Each User can have many UserClaims b.HasMany(e => e.Claims) .WithOne() .HasForeignKey(uc => uc.UserId) .IsRequired(); // Each User can have many UserLogins b.HasMany(e => e.Logins) .WithOne() .HasForeignKey(ul => ul.UserId) .IsRequired(); // Each User can have many UserTokens b.HasMany(e => e.Tokens) .WithOne() .HasForeignKey(ut => ut.UserId) .IsRequired(); // Each User can have many entries in the UserRole join table b.HasMany(e => e.UserRoles) .WithOne(e => e.User) .HasForeignKey(ur => ur.UserId) .IsRequired(); }); builder.Entity <CustomerRole>(b => { // Each Role can have many entries in the UserRole join table b.HasMany(e => e.UserRoles) .WithOne(e => e.Role) .HasForeignKey(ur => ur.RoleId) .IsRequired(); }); var roles = new[] { new CustomerRole("Admin") }; var users = new[] { new UserModel { Email = "*****@*****.**", UserName = "******", NormalizedUserName = StringNormalizationExtensions.Normalize("*****@*****.**"), FirstName = "Ferris", LastName = "DeHart", DOB = new DateTime(2000, 7, 7), EmailConfirmed = true } }; users[0].PasswordHash = new PasswordHasher <UserModel>().HashPassword(users[0], "Bueller7!"); var userRoles = new[] { new CustomerUserRole { UserId = users[0].Id, RoleId = roles[0].Id } }; builder.Entity <UserModel>().HasData(users); builder.Entity <CustomerRole>().HasData(roles); builder.Entity <CustomerUserRole>().HasData(userRoles); }