I can't create instance variables using other classes

The code below is what I have gotten to so far but I am not able to access the ActionMaster class from the test script. All of the ActionMaster type thingy’s (what do you call those?) are giving me red squiggles. I tried fiddling with the folder location and a little bit of namespace stuff (though I don’t know too much about that). Help would be greatly appreciated!


using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;

public class ActionMasterTest {

private ActionMaster.Action endTurn = ActionMaster.Action.EndTurn;

[Test]
public void T00ActionMasterTestSimplePasses() {
    Assert.AreEqual(1, 1);
}

[Test]
public void T01OneStrikeReturnsEndTurn()
{
    Assert.AreEqual(endTurn, actionMaster.Bowl(10));
}

}


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ActionMaster : MonoBehaviour {

public enum Action { Tidy, Reset, EndTurn, EndGame};

public Action Bowl(int pins) {
    if (pins == 10)
    {
        return Action.EndTurn;
    }
    return Action.EndGame;
}

}

I think I got it working. I took the code that Rob posted previously and put it into a new c# script - NOT the script that is created by the test runner window. I made some modifications as per the lecture for this section and here is what I ended up with. It seems to be working. I noticed that I didn’t have the test fixture attribute on the class. This may be what caused the problem. I will definitely post if I have any more issues.


using System;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;

[TestFixture]
public class ActionMasterTest
{
private ActionMaster.Action endTurn = ActionMaster.Action.EndTurn;

[Test]
public void PassingTest()
{
    ActionMaster actionMaster = new ActionMaster();
    Assert.AreEqual(endTurn, actionMaster.Bowl(10));
}

}

Privacy & Terms