Is there a way to verify that a UnityEngine.Object.Destroy() method is called for a specific GameObject? Since the UnityEngine.Object is no interface I cannot mock it and check for Verifiable(). I am using C#, NUnit and Moq.
For example:
UnityEngine.Object.Destroy(audioSource);
The only thing I found was this How to Mock (with Moq) Unity methods but this is not what I need.
I appreciate any help or further information about this topic!
One thing I also did was that I extract the call from above into the calling interface and verify that this method is called, but this way I only shift the problem to another layer.
public interface IAudioSource
{
void DestroyUnityObject();
}
Then I can call the Unity Destroy method in there.
public void DestroyUnityObject()
{
UnityEngine.Object.Destroy(mAudioSource);
}
And mock the upper method call.
audioSourceMock.Setup(s => s.DestroyUnityObject()).Verifiable();
But as I said, this only puts the problem elsewhere and I can still not verify that the Unity method is called correctly.