public void ClassWithUnityObject_WhenValueIsNull_CanBeSerializedAndDeserialized() { var src = new ClassWithUnityObjects(); var dst = SerializeAndDeserialize(src); Assert.That(dst, Is.Not.SameAs(src)); Assert.That(dst.ObjectValue, Is.EqualTo(src.ObjectValue)); }
public void ClassWithUnityObject_WhenValueIsTexture2DAsset_CanBeSerializedAndDeserialized() { var image = new Texture2D(1, 1); AssetDatabase.CreateAsset(image, kTexture2DPath); AssetDatabase.ImportAsset(kTexture2DPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate); try { var src = new ClassWithUnityObjects { ObjectValue = image }; var dst = SerializeAndDeserialize(src); Assert.That(dst, Is.Not.SameAs(src)); Assert.That(dst.ObjectValue, Is.EqualTo(src.ObjectValue)); } finally { AssetDatabase.DeleteAsset(kTexture2DPath); } }