public void StartMapQueueCountIsFifteen() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); //Act mapGeneration.Start(new GameObject()); Queue<GameObject> queue = (Queue<GameObject>)GetInstanceField(typeof(MapGenerationScript), mapGeneration, "mapQueue"); //Assert Assert.AreEqual(queue.Count, 15); }
public void GenerateMapPieceDestroysLastPiece() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); mapGeneration.Start(new GameObject()); Queue<GameObject> queue = (Queue<GameObject>)GetInstanceField(typeof(MapGenerationScript), mapGeneration, "mapQueue"); //Act mapGeneration.GenerateMapPiece(); //Assert map.Received().DestroyThis(queue.Dequeue()); // destroyed last map queue piece }
public void StartGeneratedFourteenPieces() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); SetGameObjectPrefabs(mapGeneration); //Act mapGeneration.Start(new GameObject()); //Assert map.Received(14).InstantiateGameObject(Arg.Any<GameObject>(), Arg.Any<Vector3>(), Arg.Any<Quaternion>()); // exactly 15 times map.DidNotReceive().DestroyThis(Arg.Any<GameObject>()); // none of which were destroy calls }
public void StartBeginningPieceIsGround() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); GameObject ground = new GameObject(); mapGeneration.Ground = ground; //Act mapGeneration.Start(new GameObject()); //Assert map.Received().InstantiateGameObject(ground, new Vector3(0, 0, 0), Quaternion.identity); }
void Start() { NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece"); if (isServer) { mapGenerator = new MapGenerationScript(); mapGenerator.SetMapInterface(this); mapGenerator.SetNotificationInterface(this); mapGenerator.Ground = Ground; mapGenerator.GroundT = GroundT; mapGenerator.BridgeF = BridgeF; mapGenerator.BridgeT = BridgeT; mapGenerator.BridgeU = BridgeU; mapGenerator.Start(startPiece); } }
public void GenerateMapPiece() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); mapGeneration.Start(new GameObject()); map.ClearReceivedCalls(); //Act mapGeneration.GenerateMapPiece(); //Assert map.Received(1).InstantiateGameObject(Arg.Any<GameObject>(), Arg.Any<Vector3>(), Arg.Any<Quaternion>()); // received only 2 calls, one is instantiate map.Received(1).DestroyThis(Arg.Any<GameObject>()); // one was a destroy call }
public void GenerateMapPiece() { //Arrange MapGenerationScript mapGeneration = new MapGenerationScript(); var map = GetMapMock(); mapGeneration.SetMapInterface(map); mapGeneration.Start(new GameObject()); map.ClearReceivedCalls(); //Act mapGeneration.GenerateMapPiece(); //Assert map.Received(1).InstantiateGameObject(Arg.Any <GameObject>(), Arg.Any <Vector3>(), Arg.Any <Quaternion>()); // received only 2 calls, one is instantiate map.Received(1).DestroyThis(Arg.Any <GameObject>()); // one was a destroy call }
// Use this for initialization void Start () { mapGenerator = new MapGenerationScript(); mapGenerator.SetMapInterface(this); mapGenerator.SetNotificationInterface(this); mapGenerator.Ground = Ground; mapGenerator.GroundT = GroundT; mapGenerator.BridgeF = BridgeF; mapGenerator.BridgeT = BridgeT; mapGenerator.BridgeU = BridgeU; mapGenerator.Start(startPiece); NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece"); NotificationCenter.DefaultCenter().AddObserver(this, "IncreaseLevel"); if(!_debugging) StartCoroutine(GenerateMapPiece()); Instantiate(car, new Vector3(0,0.25f,0), Quaternion.identity); }
// Use this for initialization void Start() { mapGenerator = new MapGenerationScript(); mapGenerator.SetMapInterface(this); mapGenerator.SetNotificationInterface(this); mapGenerator.Ground = Ground; mapGenerator.GroundT = GroundT; mapGenerator.BridgeF = BridgeF; mapGenerator.BridgeT = BridgeT; mapGenerator.BridgeU = BridgeU; mapGenerator.Start(startPiece); NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece"); NotificationCenter.DefaultCenter().AddObserver(this, "IncreaseLevel"); if (!_debugging) { StartCoroutine(GenerateMapPiece()); } Instantiate(car, new Vector3(0, 0.25f, 0), Quaternion.identity); }
private void SetGameObjectPrefabs(MapGenerationScript mapGeneration) { mapGeneration.Ground = new GameObject(); mapGeneration.GroundT = new GameObject(); mapGeneration.BridgeF = new GameObject(); mapGeneration.BridgeT = new GameObject(); mapGeneration.BridgeU = new GameObject(); }