68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
|
|
using TeamsISO.App.ViewModels;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace TeamsISO.App.Tests;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Validates the title-stripping heuristic used by the IN-CALL bar pill.
|
||
|
|
/// Teams' raw window title is the format the user actually sees (or doesn't —
|
||
|
|
/// when auto-hide is on); we want to surface the meaningful meeting-name
|
||
|
|
/// portion without the "| Microsoft Teams" suffix bloating the pill.
|
||
|
|
/// </summary>
|
||
|
|
public class MeetingTitleExtractionTests
|
||
|
|
{
|
||
|
|
[Theory]
|
||
|
|
[InlineData("Weekly Standup | Microsoft Teams", "Weekly Standup")]
|
||
|
|
[InlineData("Meeting with Alice | Microsoft Teams", "Meeting with Alice")]
|
||
|
|
[InlineData("Q4 Planning - Microsoft Teams", "Q4 Planning")]
|
||
|
|
[InlineData("Meeting | Teams", "Meeting")]
|
||
|
|
public void StripsTeamsSuffix(string raw, string expected)
|
||
|
|
{
|
||
|
|
Assert.Equal(expected, MainViewModel.ExtractMeetingTitle(raw));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void EmptyInput_ReturnsEmpty()
|
||
|
|
{
|
||
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle(string.Empty));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Whitespace_ReturnsEmpty()
|
||
|
|
{
|
||
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle(" "));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void BareAppTitle_ReturnsEmpty()
|
||
|
|
{
|
||
|
|
// "Microsoft Teams" alone means no meeting context — pill should
|
||
|
|
// stay at plain "IN CALL" rather than appending a meaningless title.
|
||
|
|
Assert.Equal(string.Empty, MainViewModel.ExtractMeetingTitle("Microsoft Teams"));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void LongTitle_GetsTruncated()
|
||
|
|
{
|
||
|
|
var long_ = new string('A', 100) + " | Microsoft Teams";
|
||
|
|
var result = MainViewModel.ExtractMeetingTitle(long_);
|
||
|
|
Assert.True(result.Length <= 50);
|
||
|
|
Assert.EndsWith("…", result);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void OuterWhitespaceIsTrimmed()
|
||
|
|
{
|
||
|
|
// Real Teams uses single-space format " | Microsoft Teams"; we only
|
||
|
|
// promise to trim outer whitespace, not normalize internal padding.
|
||
|
|
Assert.Equal("Project sync", MainViewModel.ExtractMeetingTitle(" Project sync | Microsoft Teams "));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void TitleWithoutSeparator_PassesThrough()
|
||
|
|
{
|
||
|
|
// If Teams emits an unrecognized format, return it as-is (clamped to 50).
|
||
|
|
Assert.Equal("Quick chat", MainViewModel.ExtractMeetingTitle("Quick chat"));
|
||
|
|
}
|
||
|
|
}
|