コード例 #1
0
        public void InsertCoin_Fail()
        {
            var mockHttpContext = new Mock <HttpContextBase>();
            var response        = new Mock <HttpResponseBase>();

            mockHttpContext.SetupGet(x => x.Response).Returns(response.Object);

            controller = new JarController(_mockCoinJar.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = mockHttpContext.Object
                }
            };


            _mockCoinJar.Setup(s => s.AddCoin(It.IsAny <ICoin>()));
            _mockCoinJar.Setup(s => s.OuncesLeft()).Returns(42);
            controller.HttpContext.Response.StatusCode = 400;

            var result = controller.InsertCoin(null);

            Assert.IsNotNull(result);

            JsonResult jsonResult = result as JsonResult;

            Assert.IsTrue(jsonResult.Data.ToString().Contains("Error"));
            Assert.IsTrue(jsonResult.Data.ToString().Contains("Invalid coinValue"));
        }
コード例 #2
0
        public void JarIndex_Success()
        {
            controller = new JarController(_mockCoinJar.Object);

            var        result           = controller.Index();
            ViewResult resultViewResult = result as ViewResult;
            JarModel   resultModel      = resultViewResult.Model as JarModel;

            Assert.IsNotNull(result);
            Assert.IsTrue(resultViewResult.ViewName == "Index");
            Assert.IsTrue(resultModel.Coins.Count == 6);
        }
コード例 #3
0
        public void InsertCoin_Success()
        {
            controller = new JarController(_mockCoinJar.Object);

            _mockCoinJar.Setup(s => s.AddCoin(It.IsAny <ICoin>()));
            _mockCoinJar.Setup(s => s.OuncesLeft()).Returns(42);

            var result = controller.InsertCoin("1c");

            Assert.IsNotNull(result);

            JsonResult jsonResult = result as JsonResult;

            Assert.IsTrue(jsonResult.Data.ToString().Contains("Success"));
        }
コード例 #4
0
    void Start()
    {
        this.cameraController = Camera.main.GetComponent <CameraController> ();

        this.spawnStuffController = GameObject.FindWithTag("GameController").
                                    GetComponent <GameSpawnStuffController>();

        this.scoreController = GameObject.FindWithTag("GameController").
                               GetComponent <GameScoreController>();
        this.beeController = GameObject.FindWithTag("bee").
                             GetComponent <BeeController>();
        this.jarController = GameObject.FindWithTag("jar").
                             GetComponent <JarController>();
        this.uiManagerController = GameObject.Find("UIManager").GetComponent <UIManagerController> ();

        audioSource = GetComponents <AudioSource>();
    }