#if ENABLE_UNITTESTS
using System;
using UnityEngine;
using NUnit.Framework;
using Framework.Support;
namespace Framework.Camera {
/// Unit tests for the utility methods
[TestFixture]
internal class CameraControllerTest {
#region class TestCameraManager
/// Dummy implementation of the camera manager
private class TestCameraManager : ICameraManager {
/// Triggered when the active camera changes
public event EventHandler CameraChanged {
add { }
remove { }
}
/// Camera that is currently active
///
/// By informing the camera manager about which camera is being used, other services
/// such as a background music or ambient sound service can keep their audio sources
/// attached to the active camera.
///
public UnityEngine.Camera ActiveCamera {
get { return this.activeCamera; }
set {
++this.activeCameraAssignmentCount;
this.activeCamera = value;
}
}
/// Number of times the active camera has been assigned
public int ActiveCameraAssignmentCount {
get { return this.activeCameraAssignmentCount; }
}
/// Camera that is currently active
private UnityEngine.Camera activeCamera;
/// How often the active camera has been assigned
private int activeCameraAssignmentCount;
}
#endregion // class TestCameraManager
///
/// Verifies that the ground height determination clamps the X coordinate to
/// the left side of the ground
///
[Test]
public void CameraManagerIsInformed() {
var manager = new TestCameraManager();
var gameObject = new GameObject("Dummy");
CameraController controller = gameObject.AddComponent();
gameObject.AddComponent();
controller.CallInject(manager);
controller.InjectOnEnable();
Assert.That(manager.ActiveCameraAssignmentCount, Is.EqualTo(1));
}
}
} // namespace Framework.Camera
#endif // ENABLE_UNITTESTS