public void GetIdentityOfNonExistentUserReturnsAnonymousIdentity() { const String name = "foo"; var user = CreateFakeIuser(); IsolateGetUserByName(user, name); var result = GenFormIdentity.GetIdentity(name); Assert.IsInstanceOfType(result, typeof(IAnonymousIdentity), "Getidentity with nonexisting user did not return AnonymousIdentity"); Assert.IsFalse(result.IsAuthenticated, "AnonymousIdentity should not be authenticated"); }
public void GetIdentityOfSystemUserWithWrongPasswordShouldReturnAnonymousIdentity() { const String name = "Admin"; var user = CreateFakeIuser(); Isolate.WhenCalled(() => user.Name).WillReturn("Admin"); Isolate.WhenCalled(() => user.Password).WillReturn("lkjlj"); IsolateGetUserByName(user, name); var result = GenFormIdentity.GetIdentity(name); Assert.IsInstanceOfType(result, typeof(AnonymousIdentity), "When passwords do not match an anonymous identity should be returned"); Assert.IsFalse(result.IsAuthenticated, "If passwords do not match, IsAuthenticated should return false"); }
public void LoginCallsSetPrincipalWithIdentity() { var user = CreateSystemUser(); var identity = CreateFakeGenFormIdentity(); Isolate.WhenCalled(() => GenFormIdentity.GetIdentity(user)).WillReturn(identity); Isolate.NonPublic.WhenCalled(typeof(GenFormPrincipal), "SetPrincipal").CallOriginal(); try { GenFormPrincipal.Login(user); Isolate.Verify.NonPublic.WasCalled(typeof(GenFormPrincipal), "SetPrincipal").WithArguments(identity); } catch (VerifyException e) { Assert.Fail("SetPrincipal was not called using a fake identity: " + e); } }