コード例 #1
0
        public async void Patch_No_Errors()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiSpaceResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiSpaceRequestModel>()))
            .Callback <int, ApiSpaceRequestModel>(
                (id, model) => model.Description.Should().Be("A")
                )
            .Returns(Task.FromResult <UpdateResponse <ApiSpaceResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiSpaceResponseModel>(new ApiSpaceResponseModel()));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiSpaceModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiSpaceRequestModel>();

            patch.Replace(x => x.Description, "A");

            IActionResult response = await controller.Patch(default(int), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <ApiSpaceRequestModel>()));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: wasimakis/PersonalProjects
        public Form1()
        {
            InitializeComponent();
            controller = new SpaceController();
            controller.AttemptConnect    += recallConnect;
            controller.ServerUpdater     += UpdateWorld;
            controller.WorldUpdater      += SizeWorldChanger;
            controller.connectionFailure += connectionFailed;


            drawingPanel = new DrawingAux.DrawingPanel(controller)
            {
                Location  = new Point(12, 46),
                Size      = new Size(250, 250),
                BackColor = System.Drawing.Color.Black
            };

            scorePanel = new DrawingAux.ScorePanel(controller)
            {
                Location  = new Point(connectButton.Location.X + connectButton.Size.Width, 46),
                Size      = new Size(250, 250),
                BackColor = System.Drawing.Color.White
            };
            this.scoreLabel.Location = new Point(this.scorePanel.Location.X + (this.scorePanel.Width / 2) - (this.scoreLabel.Width / 2), this.scoreLabel.Location.Y);
            this.Controls.Add(drawingPanel);
            this.Controls.Add(scorePanel);
            this.Enabled = true;
        }
コード例 #3
0
        public async void BulkInsert_No_Errors()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            var mockResponse = new CreateResponse <ApiSpaceResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiSpaceResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiSpaceRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiSpaceResponseModel> >(mockResponse));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiSpaceRequestModel>();

            records.Add(new ApiSpaceRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as List <ApiSpaceResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiSpaceRequestModel>()));
        }
コード例 #4
0
    public override void Initialize(object _data = null)
    {
        spaceController = SpaceController.Instance;
        player          = FindObjectOfType <PlayerController>();

        base.Initialize(_data);
        StartCoroutine(Show());
    }
コード例 #5
0
        public ActionResult FurnitureList(List <string> Left, List <string> Top, string SearchQ, string MaxP, string pageNo = "")
        {
            SpaceController.SavePositions(Left, Top);
            List <EtsyItem> items = new List <EtsyItem>();

            if (SearchQ != null && SearchQ != string.Empty)
            {
                if (pageNo != string.Empty)
                {
                    if (int.Parse(pageNo) > 1)
                    {
                        SearchQ += "&page=" + pageNo;
                    }
                }
                if (MaxP != string.Empty)
                {
                    SearchQ         += "&min_price= 0";
                    SearchQ         += "&max_price= " + MaxP;
                    TempData["MaxP"] = MaxP;
                }
                JObject data = EtsyDAL.GetEtsyAPI(" &limit=5&category=furniture&keywords=" + SearchQ, "active");
                if (SearchQ.Contains('&'))
                {
                    TempData["SearchQ"] = SearchQ.Split('&')[0];
                }
                else
                {
                    TempData["SearchQ"] = SearchQ;
                }
                int prevPage = (int)data["pagination"]["effective_page"];
                if (prevPage > 1)
                {
                    TempData["prevPage"] = prevPage - 1;
                }
                else
                {
                    TempData["prevPage"] = null;
                }
                string nextPage = data["pagination"]["next_page"].ToString();
                if (nextPage != string.Empty)
                {
                    TempData["nextPage"] = (int)data["pagination"]["next_page"];
                }
                for (int i = 0; i < data["results"].Count(); i++)
                {
                    EtsyItem newItem = new EtsyItem();
                    newItem.Listing_Id = data["results"][i]["listing_id"].ToString();
                    newItem            = EtsyDAL.MakeEtsyItem(newItem.Listing_Id);
                    items.Add(newItem);
                    System.Threading.Thread.Sleep(500);
                }
            }
            TempData["items"] = items;
            return(RedirectToAction("Index", "Space"));
        }
コード例 #6
0
        public ActionResult SearchPage(int pageNo, string searchQ, List <string> Left, List <string> Top)
        {
            SpaceController.SavePositions(Left, Top);
            string newSearchQ = searchQ;

            if (pageNo > 1)
            {
                newSearchQ += "&page=" + pageNo.ToString();
            }
            return(RedirectToAction("FurnitureList", "Search", new { SearchQ = newSearchQ }));
        }
コード例 #7
0
    private void Start()
    {
        spaceController = SpaceController.Instance;

        rg = GetComponent <Rigidbody>();

        if (rg == null)
        {
            rg = gameObject.AddComponent <Rigidbody>();
        }

        healthCurrent = healthMax;
    }
コード例 #8
0
    void Start()
    {
        GameObject gameControllerObject = GameObject.FindWithTag("SpaceController");

        if (gameControllerObject != null)
        {
            gameController = gameControllerObject.GetComponent <SpaceController>();
        }
        if (gameControllerObject == null)
        {
            Debug.Log("Connot find 'GameController' script");
        }
    }
コード例 #9
0
    // Creates the view and gets the controller for a Space
    public void CreateSpaceView(SpaceModel spaceModel)
    {
        // Creates the space GameObject in the correct position. Formula works for hexes
        GameObject spaceView = UnityEngine.Object.Instantiate(GameController.GetSpaceView(),
                                                              new Vector2((float)spaceModel.Column * 0.6f, (0 - spaceModel.Row * 1.04f)), Quaternion.identity, MapContainer);
        // Gets the controller from the GameObject.
        SpaceController spaceController = spaceView.GetComponent <SpaceController>();

        // Lets the Controller access the GameObject
        spaceController.SetSpaceView(spaceView);
        // Lets the Controller access the Model
        spaceController.SetSpace(spaceModel);
        // Lets the Model access the Controller, as a callback
        spaceModel.SetController(spaceController);
    }
コード例 #10
0
        public async void Get_Not_Exists()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiSpaceResponseModel>(null));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Get(default(int));

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #11
0
    private void UpdateTurn()
    {
        if (!spaceController)
        {
            spaceController = SpaceController.Instance;
        }
        if (!player)
        {
            player = FindObjectOfType <PlayerController>();
        }

        turns.text   = "TURN: " + spaceController.countTurns.ToString();
        sectors.text = "SECTOR: " + spaceController.countSectors.ToString();

        ammo.text = string.Format("[ key # 1 ] MINING LASER: 999\n[ key #2 ] ARMY LASER: {0}\n[ key #3 ] ROCKETS: {1}", player.thisObject.countAmmoArmy, player.thisObject.countAmmoRocket);
    }
コード例 #12
0
        public async void Delete_Errors()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();
            var mockResult = new Mock <ActionResponse>();

            mockResult.SetupGet(x => x.Success).Returns(false);
            mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Delete(default(int));

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>()));
        }
コード例 #13
0
        public async void Update_NotFound()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiSpaceResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(false);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiSpaceRequestModel>())).Returns(Task.FromResult <UpdateResponse <ApiSpaceResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiSpaceResponseModel>(null));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiSpaceModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Update(default(int), new ApiSpaceRequestModel());

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #14
0
        public async void Get_Exists()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new ApiSpaceServerResponseModel()));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Get(default(int));

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var record = (response as OkObjectResult).Value as ApiSpaceServerResponseModel;

            record.Should().NotBeNull();
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #15
0
        public async void All_Not_Exists()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <ApiSpaceResponseModel> >(new List <ApiSpaceResponseModel>()));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.All(1000, 0);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var items = (response as OkObjectResult).Value as List <ApiSpaceResponseModel>;

            items.Should().BeEmpty();
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
コード例 #16
0
ファイル: Board.cs プロジェクト: HannoCombrinck/Pentago
    private void Awake()
    {
        Debug.Assert(game != null, "Game component required.");
        Debug.Assert(player1MarblePrefab != null, "Prefab required.");
        Debug.Assert(player1MarblePreviewPrefab != null, "Prefab required.");
        Debug.Assert(player2MarblePrefab != null, "Prefab required.");
        Debug.Assert(player2MarblePreviewPrefab != null, "Prefab required.");

        player1MarblePreview = Instantiate(player1MarblePreviewPrefab);
        player1MarblePreview.SetActive(false);
        player2MarblePreview = Instantiate(player2MarblePreviewPrefab);
        player2MarblePreview.SetActive(false);

        quadrants = GetComponent <QuadrantController>();
        spaces    = GetComponent <SpaceController>();

        game.onNewGameStarted.AddListener(OnGameStarted);
        game.onActionExecuted.AddListener(ApplyGameStateToVisuals);
        game.onGameWon.AddListener(OnGameEnded);
    }
コード例 #17
0
        public async void Patch_Record_Not_Found()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();
            var mockResult = new Mock <ActionResponse>();

            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiSpaceResponseModel>(null));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiSpaceRequestModel>();

            patch.Replace(x => x.Description, "A");

            IActionResult response = await controller.Patch(default(int), patch);

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #18
0
        public async void Create_No_Errors()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            var mockResponse = ValidationResponseFactory <ApiSpaceServerResponseModel> .CreateResponse(null as ApiSpaceServerResponseModel);

            mockResponse.SetRecord(new ApiSpaceServerResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiSpaceServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiSpaceServerResponseModel> >(mockResponse));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Create(new ApiSpaceServerRequestModel());

            response.Should().BeOfType <CreatedResult>();
            (response as CreatedResult).StatusCode.Should().Be((int)HttpStatusCode.Created);
            var createResponse = (response as CreatedResult).Value as CreateResponse <ApiSpaceServerResponseModel>;

            createResponse.Record.Should().NotBeNull();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiSpaceServerRequestModel>()));
        }
コード例 #19
0
        public async void BulkInsert_Errors()
        {
            SpaceControllerMockFacade mock = new SpaceControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiSpaceServerResponseModel> >(null as ApiSpaceServerResponseModel);

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiSpaceServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiSpaceServerResponseModel> >(mockResponse.Object));
            SpaceController controller = new SpaceController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiSpaceServerRequestModel>();

            records.Add(new ApiSpaceServerRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiSpaceServerRequestModel>()));
        }
コード例 #20
0
 public void SetUp()
 {
     _spaceController = new SpaceController(_spaceService, _spaceTreeService, _requestProvider.Object, _contextService.Object);
 }
コード例 #21
0
 private void Awake()
 {
     _spaceController = new SpaceController(this);
     _viewController  = new ViewController(this);
 }
コード例 #22
0
 public ScorePanel(SpaceController controller)
 {
     DoubleBuffered  = true;
     this.controller = controller;
 }
コード例 #23
0
 public void SetController(SpaceController controller)
 {
     this.controller = controller;
 }
コード例 #24
0
 private void Start()
 {
     spaceController = SpaceController.Instance;
     thisObject      = GetComponent <SpaceObjects>();
 }
コード例 #25
0
    // public void onSpaceClicked( int spaceIndex, float x, float y ){
    public void onSpaceClicked(SpaceController space)
    {
        int   spaceIndex = space.spaceIndex;
        float x          = space.gameObject.transform.position.x;
        float y          = space.gameObject.transform.position.y;

        if (gameIsOver)
        {
            return;
        }

        Vector2Int rowCol = getRowColFromIndex(spaceIndex);
        int        row    = rowCol.x;
        int        col    = rowCol.y;

        //don't allow moves on non-empty spaces
        if (boardData[row, col] > 0)
        {
            return;
        }

        numMoves++;
        space.SetIsFull(true);

        currPlayerController.MovePieceTo(x, y);
        audioSource.PlayOneShot(moveClip, 1.0f);

        //update the board
        boardData[row, col] = currPlayer;

        //check for wins
        gameIsOver = checkForWin(rowCol);
        // Debug.Log("Winner? " + gameIsOver);

        //if nine moves made, draw.
        if (!gameIsOver && numMoves >= 9)
        {
            // Debug.Log("It's a tie!");
            gameIsOver = true;
            isTied     = true;
            audioSource.PlayOneShot(tieClip, 1.0f);
        }

        //switch currPlayer
        if (gameIsOver)
        {
            restartButton.SetActive(true);
            if (!isTied)
            {
                audioSource.PlayOneShot(winClip, 1.0f);

                otherPlayerController.OnGameOver(false);
                currPlayerController.OnGameOver(true);
            }
        }
        else
        {
            switchPlayer();
        }

        // printBoardData();
        updateHeaderText();
    }
コード例 #26
0
 public DrawingPanel(SpaceController controller)
 {
     DoubleBuffered  = true;
     this.controller = controller;
 }