Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 0cfbf8f

Browse files
committed
Minor test refactor for readability
1 parent 6af1872 commit 0cfbf8f

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

Slack-GPT-Tests/Handlers/CommandHandlerTests.cs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,17 @@ public async Task HelpCommand_CustomGlobal_Ok(string? userId)
9090
});
9191

9292
// Act
93-
var generalResponse = await _commandManager.Execute(new SlashCommand()
94-
{
95-
Text = "help",
96-
UserId = "U0123ID"
97-
});
98-
93+
await ExecuteAndAssertSlashCommand("help", "U0123ID", "This is a custom command");
94+
await ExecuteAndAssertSlashCommand("help -customCommand", "U0123ID", "This is a custom command");
95+
await ExecuteAndAssertSlashCommand("help -customcommand", "U0123ID", "This is a custom command");
96+
}
97+
98+
private async Task ExecuteAndAssertSlashCommand(string commandText, string userId, string expectedText)
99+
{
99100
var response = await _commandManager.Execute(new SlashCommand()
100101
{
101-
Text = "help -customCommand",
102-
UserId = "U0123ID"
103-
});
104-
105-
var caseInsensitiveResponse = await _commandManager.Execute(new SlashCommand()
106-
{
107-
Text = "help -customcommand",
108-
UserId = "U0123ID"
102+
Text = commandText,
103+
UserId = userId
109104
});
110105

111106
// Assert
@@ -114,20 +109,6 @@ public async Task HelpCommand_CustomGlobal_Ok(string? userId)
114109
var text = (response.Message.Blocks[0] as SectionBlock)!.Text.Text;
115110
Console.WriteLine(text);
116111
text.Should().NotBeNullOrEmpty();
117-
text.Should().Contain("This is a custom command");
118-
119-
generalResponse.Message.Blocks[0].Should().BeOfType<SectionBlock>();
120-
generalResponse.Message.Blocks[0].Should().NotBeNull();
121-
text = (generalResponse.Message.Blocks[0] as SectionBlock)!.Text.Text;
122-
Console.WriteLine(text);
123-
text.Should().NotBeNullOrEmpty();
124-
text.Should().Contain("This is a custom command");
125-
126-
caseInsensitiveResponse.Message.Blocks[0].Should().BeOfType<SectionBlock>();
127-
caseInsensitiveResponse.Message.Blocks[0].Should().NotBeNull();
128-
text = (caseInsensitiveResponse.Message.Blocks[0] as SectionBlock)!.Text.Text;
129-
Console.WriteLine(text);
130-
text.Should().NotBeNullOrEmpty();
131-
text.Should().Contain("This is a custom command");
112+
text.Should().Contain(expectedText);
132113
}
133114
}

0 commit comments

Comments
 (0)