public void GetSpotById_99_ShouldReturnNull() { _service = new SpotController(_fakeRepository); var serviceCall = _service.GetSpotById(99); serviceCall.Result.ShouldBe(null); }
public async Task <ActionResult> AddSpot_ShouldReturnCorrectStatusCode(SpotDto dto) { _service = new SpotController(_fakeRepository); var serviceCall = _service.AddSpot(dto); return(await serviceCall as ObjectResult); }
public void GetSpotById_2_ShouldReturnSecondSpot() { _service = new SpotController(_fakeRepository); var serviceCall = _service.GetSpotById(2); serviceCall.Result.Id.ShouldBe(2); serviceCall.Result.ShouldNotBeNull(); }
public void GetAllSpots_ShouldReturnFourSpots() { _service = new SpotController(_fakeRepository); var serviceCall = _service.GetAllSpots(); serviceCall.Result.Count.ShouldBe(4); serviceCall.Result.ShouldNotBeNull(); serviceCall.Result.ShouldNotBeEmpty(); }
public async Task GetSpots_HaveTwoSpots_ReturnOkEmptyList() { //Arrange Mapper.Initialize(cfg => { cfg.CreateMap <City, CityDto>(); cfg.CreateMap <Spot, SpotDto>() .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.Type.Name)); }); var cityInfoRepoMock = new Mock <ICityInfoRepository>(); var loggerMock = new Mock <ILogger <SpotController> >(); var urlHelperMock = new Mock <IUrlHelper>(); var param = new SpotResourceParameters() { cityId = 1, SearchQuery = "", Type = "" }; cityInfoRepoMock.Setup(c => c.GetSpotsForCity(param)).Returns(() => new List <Spot>() { new Spot() { Id = 1, CityId = 1, Name = "Test Spot 1", Description = "Desc 1" }, new Spot() { Id = 2, CityId = 1, Name = "Test Spot 2", Description = "Desc 2" } }); var controller = new SpotController(cityInfoRepoMock.Object, loggerMock.Object, urlHelperMock.Object); //Act var result = controller.GetSpotsInCity(param); //Assert var okResult = result.Should().BeOfType <OkObjectResult>(); var spots = okResult.Subject.Value.Should().BeAssignableTo <LinkedCollectionResourceWrapperDto <SpotDto> >().Subject; spots.Value.Count().Should().Be(2); }
void cutDownTrees() { if (getEmptySpots().Count <= destroyTreesWhen) { timeBeforeNextTreeCut -= Time.deltaTime; } List <SpotController> treesEnabled = getPopulatedGoodSpots(); if (timeBeforeNextTreeCut <= 0f && treesEnabled.Count > 0) { SpotController randomTreeSpot = treesEnabled[Random.Range(0, treesEnabled.Count)]; randomTreeSpot.trees.GetComponent <Animator>().SetTrigger("Shrink"); randomTreeSpot.ShrunkTrees = true; pollution.IncreasePollution(); ResetTreeCutCounter(); } }
void Update() { float p = currentHeat / Heat.Powah; rend.material.color = new Color(1f, 1f, 1f, p); float distanceFromOrigin = Vector3.Distance(Origin.position, this.transform.position); float percentage = distanceFromOrigin / Heat.Distance; this.transform.position += Direction * DataManager.Instance.HeatSpeed; //currentHeat -= DataManager.Instance.HeatDecay; currentHeat = Heat.Powah * (1 - percentage); if (distanceFromOrigin >= Heat.Distance) { GameObject.Destroy(this.gameObject); } Vector3 fwd = transform.TransformDirection(Vector3.right); Debug.DrawRay(transform.position, fwd * 1f, Color.green); RaycastHit objectHit; Ray ray = new Ray(); ray.origin = this.transform.position; ray.direction = fwd; //Physics.Raycast(transform.position, out objectHit, 1f, DataManager.Instance.FoodHit) //if (Physics.Raycast(transform.position, out objectHit, fwd, 1f, DataManager.Instance.FoodHit)) if (Physics.Raycast(ray, out objectHit, 1f, DataManager.Instance.FoodHit)) { // Debug.LogWarning("Flag 0: " + objectHit); SpotController spot = objectHit.transform.parent.transform.GetComponent <SpotController>(); if (!HitSpots.Contains(spot)) { spot.HitWithHeat(currentHeat); HitSpots.Add(spot); SoundSystem.Instance.PlaySound(Heat.Sound); } } }
public async Task GetSpots_EmptySpots_ReturnNotFound() { //Arrange var cityInfoRepoMock = new Mock <ICityInfoRepository>(); var loggerMock = new Mock <ILogger <SpotController> >(); var urlHelperMock = new Mock <IUrlHelper>(); var param = new SpotResourceParameters() { cityId = 1, SearchQuery = "", Type = "" }; cityInfoRepoMock.Setup(c => c.GetSpotsForCity(param)).Returns(() => new List <Spot>()); var controller = new SpotController(cityInfoRepoMock.Object, loggerMock.Object, urlHelperMock.Object); //Act var result = controller.GetSpotsInCity(param); //Assert var notFound = result.Should().BeOfType <NotFoundResult>(); }
public void AddSpot(SpotController spotController) { _spots.Add(spotController); spotController.Init(this); }
public void AddSpot(SpotController s) { spots.Add(s); }
// Use this for initialization void Start() { GameObject SpotController = GameObject.Find("ControlSpot"); SpotControllerScript = SpotController.GetComponent <SpotController>(); }
// Use this for initialization void Start () { GameObject SpotController = GameObject.Find("ControlSpot"); SpotControllerScript = SpotController.GetComponent<SpotController>(); }
private void Start() { pollution = FindObjectOfType <Pollution>(); spotController = transform.parent.GetComponent <SpotController>(); }