示例#1
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());
        }
示例#2
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());
        }
示例#3
0
        public void RequireCurrentUser_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.RequireCurrentUser();

            // Assert
            Assert.AreSame(user, result);
        }