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);
}