public void GetLoginPackageTest() { var package = new LoginPackage(); var data = package.ToByteArray(); ClientPackage clientPackage = _factory.GetNextPackage(data); Assert.NotNull(clientPackage); Assert.AreEqual(data, clientPackage.ToByteArray()); Assert.AreEqual(package.Type, clientPackage.Type); }
public void LoginPackageDeserializationTest() { LoginPackage expected = new LoginPackage(); var buffer = expected.ToByteArray(); ClientPackageType packageType = ClientPackageType.None; LoginPackage actual = new LoginPackage(); using (var stream = new MemoryStream(buffer)) { using (var reader = new BinaryReader(stream)) { var len = reader.ReadInt32(); packageType = (ClientPackageType)reader.ReadByte(); actual.FromByteArray(reader.ReadBytes(len - 1)); } } Assert.AreEqual(ClientPackageType.Login, packageType); }