public async Task RejectIfNoGameRunning() { RequireReaderAttribute attribute = new RequireReaderAttribute(); ICommandContext context = CreateCommandContext(DefaultChannelId, AdminId); GameStateManager gameStateManager = new GameStateManager(); IServiceProvider serviceProvider = CreateServiceProvider(gameStateManager); PreconditionResult result = await attribute.CheckPermissionsAsync(context, null, serviceProvider); Assert.IsFalse(result.IsSuccess, "Check should have failed."); }
private static async Task TestUser(ulong userId, bool acceptanceExpected) { RequireReaderAttribute attribute = new RequireReaderAttribute(); ICommandContext context = CreateCommandContext(DefaultChannelId, userId); GameStateManager gameStateManager = new GameStateManager(); gameStateManager.TryCreate(DefaultChannelId, out GameState gameState); gameState.ReaderId = ReaderId; IServiceProvider serviceProvider = CreateServiceProvider(gameStateManager); PreconditionResult result = await attribute.CheckPermissionsAsync(context, null, serviceProvider); if (acceptanceExpected) { Assert.IsTrue(result.IsSuccess, "User should have been accepted as a reader."); } else { Assert.IsFalse(result.IsSuccess, "User shouldn't have been accepted as a reader."); } }