fix: tests
This commit is contained in:
@@ -28,9 +28,9 @@ public sealed class CollectionInviteTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WithOwnerRole_ThrowsDomainException()
|
||||
public void Create_WithOwnerRole_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
Assert.Throws<DomainException>(() =>
|
||||
Assert.Throws<InsufficientPermissionException>(() =>
|
||||
CollectionInvite.Create(CollectionId, CreatorId, CollectionRole.Owner));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ public sealed class CollectionTests
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void Create_WithEmptyName_ThrowsDomainException(string name)
|
||||
public void Create_WithEmptyName_ThrowsDomainValidationException(string name)
|
||||
{
|
||||
Assert.Throws<DomainException>(() => Collection.Create(Owner, name));
|
||||
Assert.Throws<DomainValidationException>(() => Collection.Create(Owner, name));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WithNameOver100Chars_ThrowsDomainException()
|
||||
public void Create_WithNameOver100Chars_ThrowsDomainValidationException()
|
||||
{
|
||||
var longName = new string('x', 101);
|
||||
Assert.Throws<DomainException>(() => Collection.Create(Owner, longName));
|
||||
Assert.Throws<DomainValidationException>(() => Collection.Create(Owner, longName));
|
||||
}
|
||||
|
||||
// ── CreateInbox ───────────────────────────────────────────────────────────
|
||||
@@ -84,20 +84,20 @@ public sealed class CollectionTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rename_ByViewer_ThrowsDomainException()
|
||||
public void Rename_ByViewer_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
var c = Collection.Create(Owner, "Test");
|
||||
c.AddMember(Other, CollectionRole.Viewer, Owner);
|
||||
|
||||
Assert.Throws<DomainException>(() => c.Rename("New", Other));
|
||||
Assert.Throws<InsufficientPermissionException>(() => c.Rename("New", Other));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rename_ByNonMember_ThrowsDomainException()
|
||||
public void Rename_ByNonMember_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
var c = Collection.Create(Owner, "Test");
|
||||
|
||||
Assert.Throws<DomainException>(() => c.Rename("New", Other));
|
||||
Assert.Throws<InsufficientPermissionException>(() => c.Rename("New", Other));
|
||||
}
|
||||
|
||||
// ── AddMember ─────────────────────────────────────────────────────────────
|
||||
@@ -113,11 +113,11 @@ public sealed class CollectionTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddMember_WithOwnerRole_ThrowsDomainException()
|
||||
public void AddMember_WithOwnerRole_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
var c = Collection.Create(Owner, "Test");
|
||||
|
||||
Assert.Throws<DomainException>(() => c.AddMember(Other, CollectionRole.Owner, Owner));
|
||||
Assert.Throws<InsufficientPermissionException>(() => c.AddMember(Other, CollectionRole.Owner, Owner));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -133,12 +133,12 @@ public sealed class CollectionTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddMember_ByNonOwner_ThrowsDomainException()
|
||||
public void AddMember_ByNonOwner_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
var c = Collection.Create(Owner, "Test");
|
||||
c.AddMember(Other, CollectionRole.Manager, Owner);
|
||||
|
||||
Assert.Throws<DomainException>(() => c.AddMember(300L, CollectionRole.Viewer, Other));
|
||||
Assert.Throws<InsufficientPermissionException>(() => c.AddMember(300L, CollectionRole.Viewer, Other));
|
||||
}
|
||||
|
||||
// ── RemoveMember ──────────────────────────────────────────────────────────
|
||||
@@ -199,12 +199,12 @@ public sealed class CollectionTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetVisibility_ByNonOwner_ThrowsDomainException()
|
||||
public void SetVisibility_ByNonOwner_ThrowsInsufficientPermissionException()
|
||||
{
|
||||
var c = Collection.Create(Owner, "Test");
|
||||
c.AddMember(Other, CollectionRole.Manager, Owner);
|
||||
|
||||
Assert.Throws<DomainException>(() => c.SetVisibility(CollectionVisibility.Public, Other));
|
||||
Assert.Throws<InsufficientPermissionException>(() => c.SetVisibility(CollectionVisibility.Public, Other));
|
||||
}
|
||||
|
||||
// ── CanView ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -31,16 +31,16 @@ public sealed class MediaItemTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_TextType_WithoutCaption_ThrowsDomainException()
|
||||
public void Create_TextType_WithoutCaption_ThrowsDomainValidationException()
|
||||
{
|
||||
Assert.Throws<DomainException>(() =>
|
||||
Assert.Throws<DomainValidationException>(() =>
|
||||
MediaItem.Create(UserId, CollectionId, source: null, MediaType.Text, caption: null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_TextType_WithEmptyCaption_ThrowsDomainException()
|
||||
public void Create_TextType_WithEmptyCaption_ThrowsDomainValidationException()
|
||||
{
|
||||
Assert.Throws<DomainException>(() =>
|
||||
Assert.Throws<DomainValidationException>(() =>
|
||||
MediaItem.Create(UserId, CollectionId, source: null, MediaType.Text, caption: " "));
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ public sealed class MediaItemTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_ImageType_WithoutSource_ThrowsDomainException()
|
||||
public void Create_ImageType_WithoutSource_ThrowsDomainValidationException()
|
||||
{
|
||||
Assert.Throws<DomainException>(() =>
|
||||
Assert.Throws<DomainValidationException>(() =>
|
||||
MediaItem.Create(UserId, CollectionId, source: null, MediaType.Photo, caption: null));
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ public sealed class MediaItemTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddTag_MoreThan20_ThrowsDomainException()
|
||||
public void AddTag_MoreThan20_ThrowsDomainValidationException()
|
||||
{
|
||||
var item = MediaItem.Create(UserId, CollectionId, TelegramSource(), MediaType.Photo, null);
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
item.AddTag(new Tag($"tag{i}"));
|
||||
|
||||
Assert.Throws<DomainException>(() => item.AddTag(new Tag("overflow")));
|
||||
Assert.Throws<DomainValidationException>(() => item.AddTag(new Tag("overflow")));
|
||||
}
|
||||
|
||||
// ── RemoveTag ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using MemeVault.Domain.Exceptions;
|
||||
using MemeVault.Domain.ValueObjects;
|
||||
using Xunit;
|
||||
|
||||
@@ -22,9 +23,9 @@ public sealed class TagTests
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void Tag_EmptyOrWhitespace_ThrowsArgumentException(string value)
|
||||
public void Tag_EmptyOrWhitespace_ThrowsDomainValidationException(string value)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new Tag(value));
|
||||
Assert.Throws<DomainValidationException>(() => new Tag(value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -36,10 +37,10 @@ public sealed class TagTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tag_ExceedsMaxLength_ThrowsArgumentException()
|
||||
public void Tag_ExceedsMaxLength_ThrowsDomainValidationException()
|
||||
{
|
||||
var value = new string('a', 51);
|
||||
Assert.Throws<ArgumentException>(() => new Tag(value));
|
||||
Assert.Throws<DomainValidationException>(() => new Tag(value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user