chore: init project
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using FluentAssertions;
|
||||
using InboxIntel.Application.Search;
|
||||
using Xunit;
|
||||
|
||||
namespace InboxIntel.UnitTests;
|
||||
|
||||
public class GmailQueryParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void Parses_operators_and_free_text()
|
||||
{
|
||||
var r = GmailQueryParser.Parse("from:github.com is:unread has:attachment quarterly report");
|
||||
|
||||
r.Sender.Should().Be("github.com");
|
||||
r.IsUnread.Should().BeTrue();
|
||||
r.HasAttachments.Should().BeTrue();
|
||||
r.Query.Should().Be("quarterly report");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parses_date_range()
|
||||
{
|
||||
var r = GmailQueryParser.Parse("after:2025-01-01 before:2025-02-01");
|
||||
r.From.Should().Be(new DateOnly(2025, 1, 1));
|
||||
r.To.Should().Be(new DateOnly(2025, 2, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Empty_query_yields_empty_filters()
|
||||
{
|
||||
var r = GmailQueryParser.Parse(" ");
|
||||
r.Sender.Should().BeNull();
|
||||
r.Query.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Is_read_sets_unread_false()
|
||||
{
|
||||
GmailQueryParser.Parse("is:read").IsUnread.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\InboxIntel.Application\InboxIntel.Application.csproj" />
|
||||
<ProjectReference Include="..\..\src\InboxIntel.Infrastructure\InboxIntel.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
using FluentAssertions;
|
||||
using InboxIntel.Infrastructure.Gmail;
|
||||
using Xunit;
|
||||
|
||||
namespace InboxIntel.UnitTests;
|
||||
|
||||
public class UnsubscribeExtractionTests
|
||||
{
|
||||
[Fact]
|
||||
public void Prefers_http_link()
|
||||
{
|
||||
var raw = "<mailto:unsub@x.com>, <https://x.com/unsub?id=42>";
|
||||
GmailMessageParser.ExtractUnsubscribeTarget(raw).Should().Be("https://x.com/unsub?id=42");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Falls_back_to_mailto()
|
||||
{
|
||||
var raw = "<mailto:unsubscribe@news.example.com>";
|
||||
GmailMessageParser.ExtractUnsubscribeTarget(raw).Should().Be("mailto:unsubscribe@news.example.com");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Null_when_absent()
|
||||
{
|
||||
GmailMessageParser.ExtractUnsubscribeTarget(null).Should().BeNull();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user