Files
James Wampler 4313c8f206 Rename Project concept to Novel across the stack
Renames the domain concept from Project to Novel throughout the backend
(entities, DTOs, services, endpoints, ProjectAccessService/Permission,
ProjectId foreign keys), MCP server (tool names and routes), and the
React/Vite frontend (types, hooks, routes, components). Adds a new EF
Core migration (RenameProjectToNovel) using RenameTable/RenameColumn to
preserve existing data instead of dropping/recreating tables. Updates
CLAUDE.md's structure section to reference Novels/ instead of Projects/.
2026-08-17 23:03:09 -07:00

47 lines
1.6 KiB
C#

using Novelly.Api.Chapters;
using Novelly.Api.Common;
using Novelly.Api.Common.Validation;
using Novelly.Api.Novels;
namespace Novelly.Api.Tests;
[TestFixture]
public class ExceptionHandlingTests : ServiceTestFixture
{
[Test]
public void Guard_rejects_an_empty_guid_passed_as_a_required_id() =>
Assert.That(() => Novels.GetAsync(Guid.Empty), Throws.TypeOf<ArgumentException>());
[Test]
public void Guard_rejects_a_null_request_object() =>
Assert.That(
() => Novels.CreateAsync(null!),
Throws.TypeOf<ArgumentNullException>());
[Test]
public async Task Deleting_a_missing_novel_returns_false_rather_than_throwing() =>
Assert.That(await Novels.DeleteAsync(Guid.NewGuid()), Is.False);
[Test]
public void A_blank_title_fails_the_create_novel_validator()
{
var result = new CreateNovelRequestValidator().Validate(new CreateNovelRequest(""));
Assert.Multiple(() =>
{
Assert.That(result.IsInvalid, Is.True);
Assert.That(result.Errors.Select(e => e.PropertyName), Has.Member("Title"));
});
}
[Test]
public void Calling_a_service_directly_with_an_invalid_request_throws_rather_than_silently_accepting_it() =>
Assert.That(
() => Novels.CreateAsync(new CreateNovelRequest("")),
Throws.TypeOf<ArgumentException>());
[Test]
public async Task Creating_a_chapter_under_a_missing_novel_returns_null_rather_than_throwing() =>
Assert.That(await Chapters.CreateAsync(Guid.NewGuid(), new CreateChapterRequest("Landfall")), Is.Null);
}