public async Task ShouldSetTheGatewayServiceReadyPropertyToTrue( string sessionId, [Frozen, Substitute] IGatewayService gateway, [Target] ReadyEventController controller ) { var cancellationToken = new CancellationToken(false); var @event = new ReadyEvent { SessionId = sessionId }; await controller.Handle(@event, cancellationToken); gateway.Received().IsReady = true; }
public async Task ShouldSetTheGatewayServiceBotId( Snowflake botId, [Frozen, Substitute] IGatewayService gateway, [Target] ReadyEventController controller ) { var cancellationToken = new CancellationToken(false); var @event = new ReadyEvent { User = new User { Id = botId } }; await controller.Handle(@event, cancellationToken); gateway.Received().BotId = botId; }
public async Task ShouldThrowIfCanceled( string sessionId, [Frozen, Substitute] IGatewayService gateway, [Target] ReadyEventController controller ) { var cancellationToken = new CancellationToken(true); var @event = new ReadyEvent { SessionId = sessionId }; Func <Task> func = () => controller.Handle(@event, cancellationToken); await func.Should().ThrowAsync <OperationCanceledException>(); gateway.DidNotReceive().SessionId = sessionId; }