0

I'm writing a card game in Unity and have a setup where all my MonoBehaviour objects communicate through SO channels. For example,

GraphicsEngine <= GameManager <=> AI

I would like to write some PlayMode unit tests that, for example, set all of the players to AI and run through a deal.

I want to do something like the following:

    public class MyTest 
    { 
        [UnityTest] 
        public IEnumerator RunThroughWithAllPlayersAI() 
        { 
            GameManager gameManager = "Some kind of mock GameManager but with Channels correctly loaded"; 
            gameManager.NSAreAI = true; 
            gameManager.waitAfterTrick = false; 
            gameManager.fixRandomSeed = false; 
            gameManager.DealCards(); 
            yield return new WaitForSeconds(1f); 
            Assert.True(true); 
        } 
} 

I'm not sure I can do this with interfaces because I don't think the SO Channels will be correctly loaded.

Rollo
  • 1
  • I don't think you're using the word channel correctly here, channel is usually a multithreading concept by my understanding. Can you please clarify what you mean by it? – Jay May 01 '23 at 17:08
  • The very first line of the code seems.. odd.. you are initializing the object gameManager as a string but then referencing parameters as bool types and even invoke a method called DealCards(). Part 2, you cannot instantiate interfaces but must define a transient that inherits the interface. – Chad May 02 '23 at 18:59
  • By Channel I mean a scriptable object that is used to send and receive messages between GameObjects. Here is an example used in a Unity Demo Project: https://www.youtube.com/watch?v=WLDgtRNK2VE. Also the first line of code is just intended to be pseudo code. – Rollo May 02 '23 at 19:50

0 Answers0