public void HelixController_IsInstanceOf_HelixController_ReceivingHelixServiceOnCreation_Test() { // Arrange var controller = new HelixController(_helixService.Object); // Act | Assert IsInstanceOf <HelixController>(controller); }
public void HelixController_GetEventById_EventByIdFromService_EventCouldNotBeFound_ReturnsNotFoundResult_Test() { // Arrange var controller = new HelixController(_helixService.Object); // Act var actionResult = controller.GetEventById(100); actionResult.Wait(); var result = actionResult.Result.Result; // Assert IsNotNull(result); Assert.IsInstanceOf(typeof(NotFoundResult), result); }
public void HelixController_GetProducts_ListIsEmpty_ReturnsOkResultWithEventListAsContent_Test() { // Arrange _helixService.Setup(m => m.GetAllEvents()).ReturnsAsync(new List <HelixEvent>().ToList()); var controller = new HelixController(_helixService.Object); // Act var actionResultTask = controller.GetProducts(); actionResultTask.Wait(); var result = actionResultTask.Result.Result as OkObjectResult; // Assert IsNotNull(result); }
private void CreateLevel(LevelData levelData) { //Random helix number int helixNumber = Random.Range(levelData.MinHelixNumber, levelData.MaxHelixNumber); //Assign values deadPieceMaterial.color = levelData.DeadPieceColor; normalPieceMaterial.color = levelData.NormalPieceColor; brokenPieceMaterial.color = levelData.BrokenPieceColor; PlayerController.Instance.SetBallColor(levelData.BallColor); pillarMaterial.color = levelData.PillarColor; TimeToPassLevel = Random.Range(levelData.MinTimeToPassLevel, levelData.MaxTimeToPassLevel); //Create the first helix HelixController firstHelixControl = Instantiate(helixPrefab, firstHelixPosition, Quaternion.identity).GetComponent <HelixController>(); firstHelixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDeadPiecesNumber), 0, levelData.NormalPieceColor, levelData.DeadPieceColor); firstHelixControl.transform.SetParent(rotaterTrans); //Calculate the height of all helixs, space and distance between the pillar and the first helix float oneHelixHeight = helixPrefab.transform.GetChild(0).GetComponent <Renderer>().bounds.size.y; float totalHelixHeight = oneHelixHeight * helixNumber - (helixNumber - 1) * oneHelixHeight + helixSpace; float totalSpace = helixSpace * (helixNumber - 1); float distance = Vector3.Distance(firstHelixPosition + Vector3.up * oneHelixHeight, pillar.transform.position); //Calculate and set the pillar's height float pillarHeight = totalSpace + totalHelixHeight + Mathf.Round(distance); pillar.transform.localScale = new Vector3(1, pillarHeight, 1); //Create helixs Vector3 nextHelixPos = firstHelixPosition + Vector3.down * helixSpace; for (int i = 0; i < helixNumber - 1; i++) { HelixController helixControl = Instantiate(helixPrefab, nextHelixPos, Quaternion.identity).GetComponent <HelixController>(); helixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDisablePiecesNumber), Random.Range(levelData.MinDeadPiecesNumber, levelData.MaxDeadPiecesNumber), levelData.NormalPieceColor, levelData.DeadPieceColor); helixControl.transform.SetParent(rotaterTrans); nextHelixPos = helixControl.transform.position + Vector3.down * helixSpace; } //Move bottomHelix object to the bottom bottomPillar.transform.position = nextHelixPos + Vector3.up * oneHelixHeight;; }
public void HelixController_PutProductsToEvent_MissingEventInfo_ReturnsBadRequestResult_Test() { // Arrange var helixEvent = CreateInValidDefaultHelixEventViewModelObject(); var controller = new HelixController(_helixService.Object); controller.ModelState.AddModelError("Id", "Required"); // Act var actionResult = controller.PutProductsToEvent(helixEvent); actionResult.Wait(); // Assert IsNotNull(actionResult); Assert.IsInstanceOf(typeof(BadRequestResult), actionResult.Result); }
public void HelixController_PutProductsToEvent_HelixEventUpdated_ReturnsOkResultWithContent_Test() { // Arrange var helixEvent = CreateValidDefaultHelixEventViewModelObject(); _helixService.Setup(m => m.Update(It.IsAny <HelixEventViewModel>())).ReturnsAsync(true); var controller = new HelixController(_helixService.Object); // Act var actionResult = controller.PutProductsToEvent(helixEvent); actionResult.Wait(); // Assert IsNotNull(actionResult); Assert.IsInstanceOf(typeof(OkResult), actionResult.Result); }
public void HelixController_GetProducts_ReturnsOkResultWithEventListAsContent_Test() { // Arrange List <HelixEvent> eventList = CreateEventList(); _helixService.Setup(m => m.GetAllEvents()).ReturnsAsync(eventList.ToList()); var controller = new HelixController(_helixService.Object); // Act var actionResultTask = controller.GetProducts(); actionResultTask.Wait(); var result = actionResultTask.Result.Result as OkObjectResult; // Assertdotne IsNotNull(result); IsNotNull(result.Value); ICollection <HelixEvent> list = (ICollection <HelixEvent>)result.Value; AreEqual(eventList.Count, list.Count); }
public void HelixController_GetEventById_EventByIdFromService_ReturnsOkWithEventEntityAsContent_Test() { // Arrange var helixEvent = CreateDefaultHelixEventObject(); _helixService.Setup(m => m.GetEventById(It.IsAny <long>())).ReturnsAsync(helixEvent); var controller = new HelixController(_helixService.Object); // Act var actionResultTask = controller.GetEventById(helixEventId); actionResultTask.Wait(); var result = actionResultTask.Result.Result as OkObjectResult; // Assert IsNotNull(result); var responseItem = (HelixEvent)result.Value; IsNotNull(responseItem); AreEqual(helixEventId, responseItem.HelixEventId); }
/// <summary> /// Creates the level using the data from levelData /// </summary> /// <param name="levelData"></param> private void CreateLevel(GameLevelData levelData) { #region Documentation //Calculate dificulty % , with 0 as minimun and 1 maximum //For example if level is between 6 and 10, difficutly would be 0,0.25,0.50,0.5 and 1 respectively, making the difficulty increasing for every level. //This value will be used for giving a integer value between 2 vars affecting difficulty. //In short , this function calculates an increasing difficulty for a level. #endregion float difficulty = (1.0f / (levelData.MaxLevel - levelData.MinLevel)) * (CurrentLevel - levelData.MinLevel); //Define how many helixes would this level have, according the difficult settings. //More advanced levels will have more helixes. //Example MinHelixNumber=25 and MaxHelixNumber=35 -> the result would be something like 25,25,30,33 and 35 int helixNumber = Mathf.RoundToInt(Mathf.Lerp(levelData.MinHelixNumber, levelData.MaxHelixNumber, difficulty)); //Random.Range(levelData.MinHelixNumber, levelData.MaxHelixNumber); //Assign colors to different pieces deadPieceMaterial.color = levelData.DeadPieceColor; normalPieceMaterial.color = levelData.NormalPieceColor; brokenPieceMaterial.color = levelData.BrokenPieceColor; PlayerController.Instance.SetBallColor(levelData.BallColor); pillarMaterial.color = levelData.PillarColor; //Calculate time needed for this leve, increasing according the level. TimeToPassLevel = Mathf.RoundToInt(Mathf.Lerp(levelData.MinTimeToPassLevel, levelData.MaxTimeToPassLevel, difficulty)); //.Range(levelData.MinTimeToPassLevel, levelData.MaxTimeToPassLevel); //Create the first helix . Every disc is a 12-pieces helix HelixController firstHelixControl = Instantiate(helixPrefab, GPC.firstHelixPosition, Quaternion.identity).GetComponent <HelixController>(); //Pass how many pieces will be disabled , how many would be a kill piece and the colors for each one firstHelixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDeadPiecesNumber), 0, levelData.NormalPieceColor, levelData.DeadPieceColor); firstHelixControl.transform.SetParent(rotaterTrans); //Calculate the height of all helixs, space and distance between the pillar and the first helix float oneHelixHeight = helixPrefab.transform.GetChild(0).GetComponent <Renderer>().bounds.size.y; float totalHelixHeight = oneHelixHeight * helixNumber - (helixNumber - 1) * oneHelixHeight + GPC.helixSpace; float totalSpace = GPC.helixSpace * (helixNumber - 1); float distance = Vector3.Distance(GPC.firstHelixPosition + Vector3.up * oneHelixHeight, pillar.transform.position); //Calculate and set the pillar's height float pillarHeight = totalSpace + totalHelixHeight + Mathf.Round(distance); pillar.transform.localScale = new Vector3(1, pillarHeight, 1); //Create helixes Vector3 nextHelixPos = GPC.firstHelixPosition + Vector3.down * GPC.helixSpace; for (int i = 0; i < helixNumber - 1; i++) { HelixController helixControl = Instantiate(helixPrefab, nextHelixPos, Quaternion.identity).GetComponent <HelixController>(); if (levelData.MovPieces) { helixControl.SetMovPiece(levelData.RandomValues, levelData.OneDirection, levelData.LerpMov, levelData.angleMov, levelData.velMov, levelData.velLerp, levelData.dstMeta, levelData.percentMov); } helixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDisablePiecesNumber), Mathf.RoundToInt(Mathf.Lerp(levelData.MinDeadPiecesNumber, levelData.MaxDeadPiecesNumber, difficulty)), levelData.NormalPieceColor, levelData.DeadPieceColor); helixControl.transform.SetParent(rotaterTrans); nextHelixPos = helixControl.transform.position + Vector3.down * GPC.helixSpace; } //Move bottomHelix object to the bottom bottomPillar.transform.position = nextHelixPos + Vector3.up * oneHelixHeight;; }