Skip to content

Commit

Permalink
Create new TurnContext using function so that derived classes can ove…
Browse files Browse the repository at this point in the history
…rride the default TurnContext (#1513)

Like happens in the regular adapter, use helper function to create new instance of the TurnContext so  so that derived classes can override the default TurnContext

Co-authored-by: Chris Mullins <cleemullins@users.noreply.github.com>
Co-authored-by: Steven Ickman <stevenic@microsoft.com>
  • Loading branch information
3 people authored Feb 19, 2020
1 parent 335357f commit c58c702
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libraries/botbuilder-core/src/testAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,22 @@ export class TestAdapter extends BotAdapter implements IUserTokenProvider {
if (!request.id) { request.id = (this.nextId++).toString(); }

// Create context object and run middleware
const context: TurnContext = new TurnContext(this, request);
const context: TurnContext = this.createContext(request);

return this.runMiddleware(context, this.logic);
}

/**
* Creates a turn context.
*
* @param request An incoming request body.
*
* @remarks
* Override this in a derived class to modify how the adapter creates a turn context.
*/
protected createContext(request: Partial<Activity>): TurnContext {
return new TurnContext(this, request);
}
/**
* Sends something to the bot. This returns a new `TestFlow` instance which can be used to add
* additional steps for inspecting the bots reply and then sending additional activities.
Expand Down

0 comments on commit c58c702

Please sign in to comment.