コード例 #1
0
 private void FullySetupLoggedInUser(User user,
                                     ICurrentUserInfo userInfo,
                                     IEntityData query,
                                     IIdentityReader identityReader)
 {
     SetupCurrentUserIdentity(user, userInfo, identityReader);
     query.Add(user);
 }
コード例 #2
0
 public AccountController(
     IIdentityReader identityReader,
     ISignInClient signInClient,
     ISignOutClient signOutClient)
 {
     IdentityReader = identityReader;
     SignInClient   = signInClient;
     SignOutClient  = signOutClient;
 }
コード例 #3
0
 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);
 }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public CurrentLoggedInUserCapabilityUserAdapter(IIdentityReader identityReader)
 {
     this.identityReader = identityReader ?? throw new ArgumentNullException(nameof(identityReader));
 }
コード例 #11
0
ファイル: LoginStateReader.cs プロジェクト: csf-dev/agiil
 public LoginStateReader(IIdentityReader userReader, IEntityData data)
 {
     this.userReader = userReader ?? throw new ArgumentNullException(nameof(userReader));
     this.data       = data ?? throw new ArgumentNullException(nameof(data));
 }