public void UnitDeserializationTest3() { Unit unit1 = new Unit { Id = 1, Position = new Position { X = 10, Y = 150 }, State = States.Stay, TargetPosition = new Position { X = 13, Y = 26 } }; var data = unit1.ToByteArray(); Unit unit2 = new Unit(); unit2.FromBytes(data); Assert.AreEqual(unit1.Id, unit2.Id); Assert.AreEqual(unit1.State, unit2.State); Assert.AreEqual(unit1.Position.X, unit2.Position.X); Assert.AreEqual(unit1.Position.Y, unit2.Position.Y); Assert.NotNull(unit2.TargetPosition); Assert.AreEqual(unit1.TargetPosition.X, unit2.TargetPosition.X); Assert.AreEqual(unit1.TargetPosition.Y, unit2.TargetPosition.Y); }
public void UnitArrayDeserializationTest() { Unit unit = new Unit { Id = 1, Position = new Position { X = 10, Y = 150 }, State = States.Stay, TargetPosition = new Position { X = 13, Y = 26 } }; Unit[] array = { unit, unit }; var data = array.ToByteArray(); Unit[] array2 = new Unit[0]; array2 = array2.FromBytes(data); Assert.AreEqual(array.Length, array2.Length); }