public void ItThrowsAnUnauthorizedAccessExceptionIfTheUserDoesNotHaveAccessToTheGamingGroup() { _currentUser.CurrentGamingGroupId = 999999; var expectedException = new UnauthorizedEntityAccessException(_currentUser.Id, _securedEntity.GetType(), _securedEntityId); var userGamingGroupQueryable = new List <UserGamingGroup> { new UserGamingGroup { GamingGroupId = _securedEntity.GamingGroupId - 1, ApplicationUserId = _currentUser.Id }, new UserGamingGroup { GamingGroupId = _securedEntity.GamingGroupId, ApplicationUserId = _currentUser.Id + "something to make it not hit" } }.AsQueryable(); _autoMocker.Get <IDataContext>().Expect(mock => mock.GetQueryable <UserGamingGroup>()) .Return(userGamingGroupQueryable); var exception = Assert.Throws <UnauthorizedEntityAccessException>( () => _autoMocker.ClassUnderTest.ValidateAccess(_securedEntity, _currentUser)); Assert.AreEqual(expectedException.Message, exception.Message); }
public void ItThrowsAnUnauthorizedAccessExceptionIfTheGamingGroupIdsDoNotMatch() { currentUser.CurrentGamingGroupId = 999999; Type stringType = typeof(string); UnauthorizedEntityAccessException expectedException = new UnauthorizedEntityAccessException(currentUser.Id, stringType, string.Empty); UnauthorizedEntityAccessException exception = Assert.Throws <UnauthorizedEntityAccessException>( () => securedEntityValidatorForSecuredEntity.ValidateAccess(securedEntity, currentUser, stringType, string.Empty)); Assert.AreEqual(expectedException.Message, exception.Message); }
public void It_Throws_An_UnauthorizedEntityAccessException_If_The_User_Requesting_The_Information_Is_Not_The_User_Being_Requested() { expectedApplicationUser = new ApplicationUser { Id = "some application user id", }; const string REQUESTED_USER_ID = "some OTHER user id"; var expectedException = new UnauthorizedEntityAccessException(expectedApplicationUser.Id, typeof(ApplicationUser), REQUESTED_USER_ID); var actualException = Assert.Throws <UnauthorizedEntityAccessException>( () => autoMocker.ClassUnderTest.RetrieveUserInformation(REQUESTED_USER_ID, expectedApplicationUser)); Assert.That(actualException.Message, Is.EqualTo(expectedException.Message)); }