mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
632ac04b56
Add message forwarding and reply lookup, friend removal and blocking endpoints, and database-backed Govor+ privileges with customizable profile tags. Include migrations, integration tests, and updated API and operations documentation.
32 lines
1.6 KiB
C#
32 lines
1.6 KiB
C#
using Govor.Application.Friends;
|
|
using Govor.Domain.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Govor.Application.Tests.Integration.Friends;
|
|
|
|
[TestFixture]
|
|
public sealed class FriendRemovalTests
|
|
{
|
|
[TestCase(FriendshipStatus.Pending)]
|
|
[TestCase(FriendshipStatus.Blocked)]
|
|
[TestCase(FriendshipStatus.Rejected)]
|
|
[TestCase(FriendshipStatus.Accepted)]
|
|
public async Task RemovalChangesOnlyAcceptedFriendshipAndRetainsHistory(FriendshipStatus status)
|
|
{
|
|
using var db = new TestDatabase();
|
|
db.Context.Friendships.Add(new Friendship { Id = Guid.NewGuid(), RequesterId = db.Alice, AddresseeId = db.Bob, Status = status });
|
|
await db.Context.SaveChangesAsync();
|
|
var message = db.AddMessage();
|
|
var service = new FriendshipService(db.Context);
|
|
await service.RemoveFriendAsync(db.Bob, db.Alice);
|
|
await service.RemoveFriendAsync(db.Alice, db.Bob);
|
|
Assert.That((await db.Context.Friendships.AsNoTracking().SingleAsync()).Status,
|
|
Is.EqualTo(status == FriendshipStatus.Accepted ? FriendshipStatus.Rejected : status));
|
|
Assert.That(await db.Context.Messages.AnyAsync(m => m.Id == message.Id), Is.True);
|
|
Assert.That(await db.Context.PrivateChats.AnyAsync(c => c.Id == db.ChatId), Is.True);
|
|
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, db.Alice));
|
|
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(Guid.Empty, db.Alice));
|
|
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, Guid.Empty));
|
|
}
|
|
}
|