コード例 #1
0
        public void ResetMainCameraWillEnableTheInitialMainCamera()
        {
            Camera initialCam = ComponentCreator.Create <Camera>();
            Camera sceneCam   = ComponentCreator.Create <Camera>();


            ICameraController stubController = Substitute.For <ICameraController>();

            stubController.FetchAttachedCamera().Returns(sceneCam);
            stubController.FetchCameras().Returns(new [] { initialCam, sceneCam });
            stubController.FetchMainCamera().Returns(initialCam);

            initialCam.enabled = true;
            sceneCam.enabled   = true;

            MainCameraSwitcherLogic logic = new MainCameraSwitcherLogic();

            logic.SetCameraController(stubController);
            logic.Initialize();

            Assert.IsFalse(initialCam.enabled);
            Assert.IsTrue(sceneCam.enabled);

            logic.ResetMainCamera();


            Assert.IsTrue(initialCam.enabled);
            Assert.IsFalse(sceneCam.enabled);
        }
コード例 #2
0
 // Callback methods that the game engine will call at appropriate times
 // Must be here, since they are called  on every MonoBehaviour attached to game objects
 private void OnEnable()
 {
     logic = new MainCameraSwitcherLogic();
     // this class is an implementation of ICameraController, so it can be set in the following way
     logic.SetCameraController(this);
     logic.Initialize();
 }
コード例 #3
0
        public void InitializationCallsCorrectMethods()
        {
            ICameraController stubController = Substitute.For <ICameraController>();

            MainCameraSwitcherLogic logic = new MainCameraSwitcherLogic();

            logic.SetCameraController(stubController);

            stubController.Received(0).FetchMainCamera();
            stubController.Received(0).FetchCameras();
            stubController.Received(0).FetchAttachedCamera();
            logic.Initialize();
            stubController.Received(1).FetchMainCamera();
            stubController.Received(1).FetchCameras();
            stubController.Received(1).FetchAttachedCamera();
        }
コード例 #4
0
        public void InitializeDoesNotDisableMainCameraIfItIsAttached()
        {
            Camera mainCamera = ComponentCreator.Create <Camera>();

            mainCamera.enabled = true;

            ICameraController stubController = Substitute.For <ICameraController>();

            stubController.FetchCameras().Returns(new[] { mainCamera, ComponentCreator.Create <Camera>(), ComponentCreator.Create <Camera>() });
            stubController.FetchAttachedCamera().Returns(mainCamera);
            stubController.FetchMainCamera().Returns(mainCamera);


            MainCameraSwitcherLogic logic = new MainCameraSwitcherLogic();

            logic.SetCameraController(stubController);
            logic.Initialize();
            Assert.IsTrue(mainCamera.enabled);
        }