Skip to content

Commit

Permalink
Change unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Nov 22, 2024
1 parent 3e88d9a commit 78a17be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,36 +718,7 @@ void CaptureSend(Activity[] arg)
}

[Fact]
public async Task TestMessageFetchTaskDefault()
{
// Arrange
var activity = new Activity
{
Type = ActivityTypes.Invoke,
Name = "message/fetchTask"
};

Activity[] activitiesToSend = null;
void CaptureSend(Activity[] arg)
{
activitiesToSend = arg;
}

var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity);

// Act
var bot = new TestActivityHandler();
await ((IBot)bot).OnTurnAsync(turnContext);

// Assert
Assert.NotNull(activitiesToSend);
Assert.Single(activitiesToSend);
Assert.IsType<InvokeResponse>(activitiesToSend[0].Value);
Assert.Equal(501, ((InvokeResponse)activitiesToSend[0].Value).Status);
}

[Fact]
public async Task TestMessageFetchTaskCustom()
public async Task TestMessageFetchTask()
{
// Arrange
var activity = new Activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,38 +1556,7 @@ void CaptureSend(Activity[] arg)
}

[Fact]
public async Task TestMessageFetchTaskDefault()
{
// Arrange
var activity = new Activity
{
Type = ActivityTypes.Invoke,
Name = "message/fetchTask"
};

Activity[] activitiesToSend = null;
void CaptureSend(Activity[] arg)
{
activitiesToSend = arg;
}

var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity);

// Act
var bot = new TestActivityHandler();
await ((IBot)bot).OnTurnAsync(turnContext);

// Assert
Assert.Single(bot.Record);
Assert.Equal("OnTeamsMessageFetchTaskAsync", bot.Record[0]);
Assert.NotNull(activitiesToSend);
Assert.Single(activitiesToSend);
Assert.IsType<InvokeResponse>(activitiesToSend[0].Value);
Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status);
}

[Fact]
public async Task TestMessageFetchTaskCustom()
public async Task TestMessageFetchTask()
{
// Arrange
var activity = new Activity
Expand All @@ -1613,6 +1582,7 @@ void CaptureSend(Activity[] arg)
Assert.Single(activitiesToSend);
Assert.IsType<InvokeResponse>(activitiesToSend[0].Value);
Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status);
Assert.Equal("http://testing", ((TaskModuleContinueResponse)((InvokeResponse)activitiesToSend[0].Value).Body).Value.Url);
}

private class NotImplementedAdapter : BotAdapter
Expand Down Expand Up @@ -1960,7 +1930,8 @@ protected override Task OnTeamsMessageSubmitActionAsync(ITurnContext<IInvokeActi

protected override Task<TaskModuleContinueResponse> OnTeamsMessageFetchTaskAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
{
var task = new TaskModuleContinueResponse();
var info = new TaskModuleTaskInfo(url: "http://testing");
var task = new TaskModuleContinueResponse(info);
Record.Add(MethodBase.GetCurrentMethod().Name);
return Task.FromResult(task);
}
Expand Down

0 comments on commit 78a17be

Please sign in to comment.