public void CorrectlyIncrementPacketTypeIds()
        {
            var networkMessagePackager = new NetworkMessagePackager();

            var first  = networkMessagePackager.AddDefinition <TestPacket>();
            var second = networkMessagePackager.AddDefinition <TestPacket2>();

            first.PacketTypeId.ShouldNotBe(second.PacketTypeId);
            second.PacketTypeId.ShouldBeGreaterThan(first.PacketTypeId);
        }
        public void AddPacketDefinitionToDictionaryCorrectly()
        {
            var networkMessagePackager = new NetworkMessagePackager();

            networkMessagePackager.AddDefinition <TestPacket>();

            networkMessagePackager.GetPacketDefinition(0)
            .PacketType.ShouldBe(typeof(TestPacket));
        }
        public void UnPackEnumPropertyCorrectly()
        {
            var networkMessagePackager = new NetworkMessagePackager();

            var testPacket = new EnumPacket()
            {
                TestEnum = TestEnum.Test
            };

            networkMessagePackager.AddDefinition <EnumPacket>();

            var value  = networkMessagePackager.Package(testPacket);
            var result = (EnumPacket)networkMessagePackager.Unpack(value);

            result.TestEnum.ShouldBe(testPacket.TestEnum);
        }
        public void UnPackCorrectly()
        {
            var networkMessagePackager = new NetworkMessagePackager();

            var testPacket = new TestPacket()
            {
                Number = 3,
                Name   = "Test"
            };

            networkMessagePackager.AddDefinition <TestPacket>();

            var value  = networkMessagePackager.Package(testPacket);
            var result = (TestPacket)networkMessagePackager.Unpack(value);

            result.Name.ShouldBe(testPacket.Name);
            result.Number.ShouldBe(testPacket.Number);
        }
        public void PackageCorrectlyBasedOnType()
        {
            var networkMessagePackager = new NetworkMessagePackager();

            var testPacket = new TestPacket()
            {
                Number = 3,
                Name   = "Test"
            };

            var definition = networkMessagePackager.AddDefinition <TestPacket>();

            var value = networkMessagePackager.Package(testPacket);

            var expectedString = $"{definition.PacketTypeId}:{testPacket.Number}:{testPacket.Name}";
            var outputString   = Encoding.UTF8.GetString(value);

            outputString.ShouldBe(expectedString);
        }