public void New_Test() { var user = new User(); var identity = new CustomIdentity<User>(user, user.Name, true); var roleProvider = new BasicRoleProvider<User>(); var principal = new CustomPrincipal<User>(identity, roleProvider); Assert.AreSame(identity, principal.Identity); Assert.AreSame(roleProvider, principal.RoleProvider); Assert.IsTrue(principal.IsInRole("any string")); Assert.Throws<ArgumentNullException>(() => new CustomPrincipal<User>(null, roleProvider)); Assert.Throws<ArgumentNullException>(() => new CustomPrincipal<User>(identity, null)); }
public void New_Test() { var user = new User(); var customIdentity = new CustomIdentity<User>(user, user.Name, true); Assert.AreSame(user, customIdentity.Reference); Assert.AreEqual("Custom", customIdentity.AuthenticationType); Assert.AreEqual(user.Name, customIdentity.Name); Assert.IsTrue(customIdentity.IsAuthenticated); Assert.Throws<ArgumentNullException>(() => new CustomIdentity<User>(null, "bob", true)); Assert.Throws<ArgumentException>(() => new CustomIdentity<User>(user, " ", true)); }