Files
pos-system/services/chat-service-net/tests/ChatService.UnitTests/Domain/Contracts/ChatHubClientTests.cs

67 lines
2.0 KiB
C#

using ChatService.Domain.Contracts;
using FluentAssertions;
using Xunit;
namespace ChatService.UnitTests.Domain.Contracts;
/// <summary>
/// EN: Unit tests for IChatHubClient interface and related DTOs.
/// VI: Unit tests cho IChatHubClient interface và các DTOs liên quan.
/// </summary>
public class ChatHubClientTests
{
[Fact]
public void MessageNotification_ShouldCreateWithAllProperties()
{
// Arrange
var id = Guid.NewGuid();
var conversationId = Guid.NewGuid();
var senderId = "user-123";
var senderName = "John Doe";
var content = "Hello, World!";
var messageType = "text";
var sentAt = DateTime.UtcNow;
var replyToMessageId = Guid.NewGuid();
// Act
var notification = new MessageNotification(
Id: id,
ConversationId: conversationId,
SenderId: senderId,
SenderName: senderName,
Content: content,
MessageType: messageType,
SentAt: sentAt,
ReplyToMessageId: replyToMessageId
);
// Assert
notification.Id.Should().Be(id);
notification.ConversationId.Should().Be(conversationId);
notification.SenderId.Should().Be(senderId);
notification.SenderName.Should().Be(senderName);
notification.Content.Should().Be(content);
notification.MessageType.Should().Be(messageType);
notification.SentAt.Should().Be(sentAt);
notification.ReplyToMessageId.Should().Be(replyToMessageId);
}
[Fact]
public void MessageNotification_ShouldAllowNullReplyToMessageId()
{
// Arrange & Act
var notification = new MessageNotification(
Id: Guid.NewGuid(),
ConversationId: Guid.NewGuid(),
SenderId: "user-123",
SenderName: "John Doe",
Content: "Hello!",
MessageType: "text",
SentAt: DateTime.UtcNow
);
// Assert
notification.ReplyToMessageId.Should().BeNull();
}
}