// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // //------------------------------------------------------------------------------ // // This source code was auto-generated by an XSL transformation. // Do not change this file. Instead, change the XML data which contains // the packet definitions and re-run the transformation (rebuild this project). // //------------------------------------------------------------------------------ namespace MUnique.OpenMU.Network.Packets.Tests.ConnectServer; using System; using System.Text; using NUnit.Framework; using MUnique.OpenMU.Network.Packets.ConnectServer; /// /// Auto-generated tests for packet structures to validate packet definitions. /// [TestFixture] public class PacketStructureTests { /// /// Tests the packet size calculation for ConnectionInfoRequest075. /// [Test] public void ConnectionInfoRequest075_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 5; var actualLength = ConnectionInfoRequest075Ref.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); // Validate field 'ServerId' boundary Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength), "Field 'ServerId' exceeds packet boundary"); } /// /// Tests the packet size calculation for ConnectionInfoRequest. /// [Test] public void ConnectionInfoRequest_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 6; var actualLength = ConnectionInfoRequestRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); // Validate field 'ServerId' boundary Assert.That(4 + 2, Is.LessThanOrEqualTo(expectedLength), "Field 'ServerId' exceeds packet boundary"); } /// /// Tests the packet size calculation for ConnectionInfo. /// [Test] public void ConnectionInfo_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 22; var actualLength = ConnectionInfoRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); // Validate field 'IpAddress' boundary Assert.That(4 + 16, Is.LessThanOrEqualTo(expectedLength), "Field 'IpAddress' exceeds packet boundary"); // Validate field 'Port' boundary Assert.That(20 + 2, Is.LessThanOrEqualTo(expectedLength), "Field 'Port' exceeds packet boundary"); } /// /// Tests the packet size calculation for ServerListRequest. /// [Test] public void ServerListRequest_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 4; var actualLength = ServerListRequestRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); } /// /// Tests the packet size calculation for ServerListResponse. /// [Test] public void ServerListResponse_PacketSizeValidation() { // Basic packet validation // Validate header type and field boundaries // Field 'ServerCount' starts at index 5 with size 2 Assert.That(5, Is.GreaterThanOrEqualTo(0), "Field 'ServerCount' has invalid negative index"); } /// /// Tests the packet size calculation for ServerListRequestOld. /// [Test] public void ServerListRequestOld_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 4; var actualLength = ServerListRequestOldRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); } /// /// Tests the packet size calculation for ServerListResponseOld. /// [Test] public void ServerListResponseOld_PacketSizeValidation() { // Basic packet validation // Validate header type and field boundaries // Field 'ServerCount' starts at index 5 with size 1 Assert.That(5, Is.GreaterThanOrEqualTo(0), "Field 'ServerCount' has invalid negative index"); } /// /// Tests the packet size calculation for Hello. /// [Test] public void Hello_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 4; var actualLength = HelloRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); } /// /// Tests the packet size calculation for PatchCheckRequest. /// [Test] public void PatchCheckRequest_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 6; var actualLength = PatchCheckRequestRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); // Validate field 'MajorVersion' boundary Assert.That(3 + 1, Is.LessThanOrEqualTo(expectedLength), "Field 'MajorVersion' exceeds packet boundary"); // Validate field 'MinorVersion' boundary Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength), "Field 'MinorVersion' exceeds packet boundary"); // Validate field 'PatchVersion' boundary Assert.That(5 + 1, Is.LessThanOrEqualTo(expectedLength), "Field 'PatchVersion' exceeds packet boundary"); } /// /// Tests the packet size calculation for PatchVersionOkay. /// [Test] public void PatchVersionOkay_PacketSizeValidation() { // Fixed-length packet validation const int expectedLength = 4; var actualLength = PatchVersionOkayRef.Length; Assert.That(actualLength, Is.EqualTo(expectedLength), "Packet length mismatch: declared length does not match calculated size"); } /// /// Tests the packet size calculation for ClientNeedsPatch. /// [Test] public void ClientNeedsPatch_PacketSizeValidation() { // Variable-length packet validation // Test GetRequiredSize method with sample data const string testString = "TestData"; var calculatedSize = ClientNeedsPatchRef.GetRequiredSize(testString); var expectedMinSize = Encoding.UTF8.GetByteCount(testString) + 1 + 6; Assert.That(calculatedSize, Is.GreaterThanOrEqualTo(expectedMinSize), "GetRequiredSize calculation incorrect for string field"); } }