ModernUO/Projects/UOContent.Tests/Tests/Items/Bulletin Boards/BulletinBoardPacketTests.cs
Kamron Batman 60a3a6f501
feat: Splits Server in Core and Application (#1806)
> [!Note]
> **Developer Note**
> Now developers will only need to build/run the Application project instead of everything.
> When adding new projects, make sure to: 
> 1. Add a reference to that project in the Application project.
> 2. Add the dll file to the Distribution/Data/assemblies.json file

### Summary
- Adds an application project
- Consolidates process restarts to use `Core.Kill(true)`
- Removes some old messaging, for example processor optimization
- Fixes missing build cleanup
2024-05-30 23:34:03 -07:00

67 lines
No EOL
2.1 KiB
C#

using Server;
using Server.Items;
using Server.Network;
using Server.Tests;
using Server.Tests.Network;
using Xunit;
namespace UOContent.Tests;
[Collection("Sequential Tests")]
public class BulletinBoardPacketTests : IClassFixture<ServerFixture>
{
[Theory]
[InlineData("Test Name")]
[InlineData(null)]
[InlineData("🅵🅰🅽🅲🆈 🆃🅴🆇🆃")]
public void TestSendBBDisplayBoard(string boardName)
{
var bb = new TestBulletinBoard(0x234) { BoardName = boardName };
var expected = new BBDisplayBoard(bb).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBBDisplayBoard(bb);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);
}
[Theory]
[InlineData("The Subject", false, "First Line", "Second Line", "Third Line")]
[InlineData("", false, "")]
[InlineData("🅵🅰🅽🅲🆈 🆃🅴🆇🆃", false, "First Line", "Second Line")]
[InlineData("The Subject", true, "First Line", "Second Line", "Third Line")]
[InlineData("", true, "")]
[InlineData("🅵🅰🅽🅲🆈 🆃🅴🆇🆃", true, "First Line", "Second Line")]
public void TestSendBBHeaderMessage(string subject, bool content, params string[] lines)
{
var poster = new Mobile((Serial)0x1024u) { Name = "Kamron" };
poster.DefaultMobileInit();
var bb = new TestBulletinBoard(0x234);
bb.PostMessage(poster, null, subject, lines);
var msg = bb.Items[0] as BulletinMessage;
var expected = (content ?
(Packet)new BBMessageContent(bb, msg) : new BBMessageHeader(bb, msg)).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBBMessage(bb, msg, content);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);
}
}
internal class TestBulletinBoard : BaseBulletinBoard
{
public TestBulletinBoard(int itemID) : base(itemID)
{
}
public TestBulletinBoard(Serial serial) : base(serial)
{
}
}