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>())); }
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; }
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>())); }
public override void Initialize(object _data = null) { spaceController = SpaceController.Instance; player = FindObjectOfType <PlayerController>(); base.Initialize(_data); StartCoroutine(Show()); }
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")); }
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 })); }
private void Start() { spaceController = SpaceController.Instance; rg = GetComponent <Rigidbody>(); if (rg == null) { rg = gameObject.AddComponent <Rigidbody>(); } healthCurrent = healthMax; }
void Start() { GameObject gameControllerObject = GameObject.FindWithTag("SpaceController"); if (gameControllerObject != null) { gameController = gameControllerObject.GetComponent <SpaceController>(); } if (gameControllerObject == null) { Debug.Log("Connot find 'GameController' script"); } }
// 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); }
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>())); }
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); }
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>())); }
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>())); }
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>())); }
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>())); }
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); }
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>())); }
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>())); }
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>())); }
public void SetUp() { _spaceController = new SpaceController(_spaceService, _spaceTreeService, _requestProvider.Object, _contextService.Object); }
private void Awake() { _spaceController = new SpaceController(this); _viewController = new ViewController(this); }
public ScorePanel(SpaceController controller) { DoubleBuffered = true; this.controller = controller; }
public void SetController(SpaceController controller) { this.controller = controller; }
private void Start() { spaceController = SpaceController.Instance; thisObject = GetComponent <SpaceObjects>(); }
// 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(); }
public DrawingPanel(SpaceController controller) { DoubleBuffered = true; this.controller = controller; }