コード例 #1
0
        public void GetSpotById_99_ShouldReturnNull()
        {
            _service = new SpotController(_fakeRepository);
            var serviceCall = _service.GetSpotById(99);

            serviceCall.Result.ShouldBe(null);
        }
コード例 #2
0
        public async Task <ActionResult> AddSpot_ShouldReturnCorrectStatusCode(SpotDto dto)
        {
            _service = new SpotController(_fakeRepository);
            var serviceCall = _service.AddSpot(dto);

            return(await serviceCall as ObjectResult);
        }
コード例 #3
0
        public void GetSpotById_2_ShouldReturnSecondSpot()
        {
            _service = new SpotController(_fakeRepository);
            var serviceCall = _service.GetSpotById(2);

            serviceCall.Result.Id.ShouldBe(2);
            serviceCall.Result.ShouldNotBeNull();
        }
コード例 #4
0
        public void GetAllSpots_ShouldReturnFourSpots()
        {
            _service = new SpotController(_fakeRepository);
            var serviceCall = _service.GetAllSpots();

            serviceCall.Result.Count.ShouldBe(4);
            serviceCall.Result.ShouldNotBeNull();
            serviceCall.Result.ShouldNotBeEmpty();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
    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();
        }
    }
コード例 #7
0
    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);
            }
        }
    }
コード例 #8
0
        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>();
        }
コード例 #9
0
ファイル: CellController.cs プロジェクト: GreatVV/tactics
 public void AddSpot(SpotController spotController)
 {
     _spots.Add(spotController);
     spotController.Init(this);
 }
コード例 #10
0
 public void AddSpot(SpotController s)
 {
     spots.Add(s);
 }
コード例 #11
0
    // Use this for initialization
    void Start()
    {
        GameObject SpotController = GameObject.Find("ControlSpot");

        SpotControllerScript = SpotController.GetComponent <SpotController>();
    }
コード例 #12
0
ファイル: gameMode.cs プロジェクト: MikeLorry/Gitaroo
	// Use this for initialization
	void Start () {
		GameObject SpotController = GameObject.Find("ControlSpot");
		SpotControllerScript = SpotController.GetComponent<SpotController>();

	}
コード例 #13
0
 private void Start()
 {
     pollution      = FindObjectOfType <Pollution>();
     spotController = transform.parent.GetComponent <SpotController>();
 }