public void TestSerializeDeserialize() { // Initialize values int id = 0; SerializableType type = SerializableType.Bench; bool isStatic = true; SerializableVector3 position = new SerializableVector3(0, 0, 0); SerializableVector3 scale = new SerializableVector3(1, 1, 1); SerializableVector3 rotation = new SerializableVector3(2, 2, 2); SerializableCharacter character = new SerializableCharacter(true, "Test"); // Serialize constructor SerializableTransformObject constructor = new SerializableTransformObject(id, type, isStatic, position, scale, rotation, character); byte[] serialized = constructor.Serialize(); // Create new SerializableTransformObject, add the serialized buffer to it SerializableTransformObject check = new SerializableTransformObject(); List <byte> transmissionBuffer = new List <byte>(); transmissionBuffer.AddRange(serialized); check.TransmissionBuffer = transmissionBuffer; // De-serialize SerializableTransformObject deserialized = check.DeSerialize(); // Check the values Assert.That(deserialized.Id, Is.EqualTo(constructor.Id)); Assert.That(deserialized.Type, Is.EqualTo(constructor.Type)); Assert.That(deserialized.IsStatic, Is.EqualTo(constructor.IsStatic)); Assert.That(deserialized.Position.X, Is.EqualTo(constructor.Position.X)); Assert.That(deserialized.Scale.Y, Is.EqualTo(constructor.Scale.Y)); Assert.That(deserialized.Rotation.Z, Is.EqualTo(constructor.Rotation.Z)); Assert.That(deserialized.Character.Name, Is.EqualTo(constructor.Character.Name)); }
public void TestCharacter() { SerializableTransformObject constructor = new SerializableTransformObject(); SerializableCharacter character = new SerializableCharacter(true, "Test"); constructor.Character = character; Assert.That(constructor.Character, Is.EqualTo(character)); }
public void TestName() { SerializableCharacter constructor = new SerializableCharacter(); string name = "TestName"; constructor.Name = name; Assert.That(constructor.Name, Is.EqualTo(name)); }
public void TestisPatient() { SerializableCharacter constructor = new SerializableCharacter(); bool isPatient = true; constructor.IsPatient = isPatient; Assert.That(constructor.IsPatient, Is.EqualTo(isPatient)); }
public void TestConstructor() { bool isPatient = true; string name = "TestConstructor"; SerializableCharacter constructor = new SerializableCharacter(isPatient, name); Assert.True(constructor is SerializableCharacter); Assert.That(constructor.IsPatient, Is.EqualTo(isPatient)); Assert.That(constructor.Name, Is.EqualTo(name)); }
public void TestConstructor() { int id = 0; SerializableType type = SerializableType.Bench; bool isStatic = true; SerializableVector3 position = new SerializableVector3(0, 0, 0); SerializableVector3 scale = new SerializableVector3(1, 1, 1); SerializableVector3 rotation = new SerializableVector3(2, 2, 2); SerializableCharacter character = new SerializableCharacter(true, "Test"); SerializableTransformObject constructor = new SerializableTransformObject(id, type, isStatic, position, scale, rotation, character); Assert.True(constructor is SerializableTransformObject); Assert.That(constructor.Id, Is.EqualTo(id)); Assert.That(constructor.Type, Is.EqualTo(type)); Assert.That(constructor.IsStatic, Is.EqualTo(isStatic)); Assert.That(constructor.Position, Is.EqualTo(position)); Assert.That(constructor.Scale, Is.EqualTo(scale)); Assert.That(constructor.Rotation, Is.EqualTo(rotation)); Assert.That(constructor.Character, Is.EqualTo(character)); }
/// <summary> /// Initializes a new instance of the <see cref="SerializableTransformObject"/> class. /// </summary> /// <param name="id">the id of the object</param> /// <param name="type">the type of the object</param> /// <param name="isStatic">whether the object is static or not</param> /// <param name="position">the position vector of the object</param> /// <param name="scale">the scale vector of the object</param> /// <param name="rotation">the rotation vector of the object</param> /// <param name="character">the serializable character object, if the type is character</param> public SerializableTransformObject(int id, SerializableType type, bool isStatic, SerializableVector3 position, SerializableVector3 scale, SerializableVector3 rotation, SerializableCharacter character) { this.Id = id; this.Type = type; this.IsStatic = isStatic; this.Position = position; this.Scale = scale; this.Rotation = rotation; this.Character = character; }