private void FullySetupLoggedInUser(User user, ICurrentUserInfo userInfo, IEntityData query, IIdentityReader identityReader) { SetupCurrentUserIdentity(user, userInfo, identityReader); query.Add(user); }
public AccountController( IIdentityReader identityReader, ISignInClient signInClient, ISignOutClient signOutClient) { IdentityReader = identityReader; SignInClient = signInClient; SignOutClient = signOutClient; }
private void SetupCurrentUserIdentity(User user, ICurrentUserInfo userInfo, IIdentityReader identityReader) { Mock.Get(userInfo) .SetupGet(x => x.Identity) .Returns(user.GetIdentity()); Mock.Get(identityReader) .Setup(x => x.GetCurrentUserInfo()) .Returns(userInfo); }
public void RequireCurrentUser_raises_exception_when_they_are_not_found([Frozen] IIdentityReader identityReader, [Frozen, InMemory] IEntityData query, CurrentUserReader sut, ICurrentUserInfo userInfo, [HasIdentity] User user) { // Arrange SetupCurrentUserIdentity(user, userInfo, identityReader); // Act & assert Assert.Throws <CurrentUserNotIdentifiedException>(() => sut.RequireCurrentUser()); }
public void RequireCurrentUser_raises_exception_when_they_are_not_logged_in([Frozen] IIdentityReader identityReader, [Frozen, InMemory] IEntityData query, CurrentUserReader sut) { // Arrange Mock.Get(identityReader) .Setup(x => x.GetCurrentUserInfo()) .Returns((ICurrentUserInfo)null); // Act & assert Assert.Throws <CurrentUserNotIdentifiedException>(() => sut.RequireCurrentUser()); }
public CurrentUserReader(IIdentityReader identityReader, IEntityData query) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (identityReader == null) { throw new ArgumentNullException(nameof(identityReader)); } this.query = query; this.identityReader = identityReader; }
public void GetCurrentUser_returns_null_when_they_are_not_found([Frozen] IIdentityReader identityReader, [Frozen, InMemory] IEntityData query, CurrentUserReader sut, ICurrentUserInfo userInfo, [HasIdentity] User user) { // Arrange SetupCurrentUserIdentity(user, userInfo, identityReader); // Act var result = sut.GetCurrentUser(); // Assert Assert.IsNull(result); }
public void GetCurrentUser_returns_null_when_they_are_not_logged_in([Frozen] IIdentityReader identityReader, [Frozen, InMemory] IEntityData query, CurrentUserReader sut) { // Arrange Mock.Get(identityReader) .Setup(x => x.GetCurrentUserInfo()) .Returns((ICurrentUserInfo)null); // Act var result = sut.GetCurrentUser(); // Assert Assert.IsNull(result); }
public void GetCurrentUser_returns_user_when_they_are_logged_in([Frozen] IIdentityReader identityReader, [Frozen, InMemory] IEntityData query, CurrentUserReader sut, ICurrentUserInfo userInfo, [HasIdentity] User user) { // Arrange FullySetupLoggedInUser(user, userInfo, query, identityReader); // Act var result = sut.GetCurrentUser(); // Assert Assert.AreSame(user, result); }
public CurrentLoggedInUserCapabilityUserAdapter(IIdentityReader identityReader) { this.identityReader = identityReader ?? throw new ArgumentNullException(nameof(identityReader)); }
public LoginStateReader(IIdentityReader userReader, IEntityData data) { this.userReader = userReader ?? throw new ArgumentNullException(nameof(userReader)); this.data = data ?? throw new ArgumentNullException(nameof(data)); }