示例#1
0
    //Function to detect a cursor entering in the trigger area of the Car icon selection
    void OnTriggerEnter2D(Collider2D trigger)
    {
        if (isActive)
        {
            WheelImage       = trigger.GetComponentInChildren <Image>();
            WheelImage.color = new Color(1f, 1f, 1f, .5f);
            return;
        }

        isActive = true;                                 //If the cursor enters the icon space the icon becomes active

        TextColorCar       = this.GetComponent <Text>(); //Get the instance of the car text and change it to yellow
        TextColorCar.color = Color.yellow;


        CPU = trigger.GetComponent <CPUController>();

        m = trigger.GetComponentInParent <MoveSelector>(); //Make the object that entered the icon space (the trigger) your moveselector target (it will be one of the cursors)
        m.is_this_inside = true;                           // Change the bool variable telling if the cursor is inside the icon area
        t   = trigger.gameObject;                          //Set the generic t object to the cursor/trigger
        old = t.transform.parent;                          //Save the current parent of the coin (the cursor) so it can be reassigned to the coin later

        ID = CPU.CoinID;
        AddTempCar();

        if (!CPU.is_coin_cpu || CPU.CoinID == 1)
        {
            ParentPosition = t.transform.localPosition;
        }
    }
示例#2
0
        public void Add_AddsEmployeeAndReturnsARedirect_WhenModelStateIsValid()
        {
            //Arrange
            var mockCPUService = new Mock <IService <IRepository <CPU>, CPU> >();

            mockCPUService.Setup(repo => repo.GetByIdAsync(1)).ReturnsAsync(GetCPU())
            .Verifiable();
            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());
            var controller  = new CPUController(mockCPUService.Object)
            {
                TempData = tempData
            };

            controller.ModelState.AddModelError("Quantity", "Required");
            var inputModel = new PCItemInputModel()
            {
                Id = 1, Quantity = 1
            };

            // Act
            var result = controller.Add(inputModel);

            // Assert
            Assert.IsType <JsonResult>(result.Result);
            mockCPUService.Verify();
        }
示例#3
0
        public void Add_ReturnsBadRequestResult_WhenModelStateIsInvalid()
        {
            // Arrange
            var mockCPUService = new Mock <IService <IRepository <CPU>, CPU> >();
            var inputModel     = new PCItemInputModel()
            {
                Id = 0, Quantity = 0
            };
            var controller = new CPUController(mockCPUService.Object);

            controller.ModelState.AddModelError("Quantity", "Required");

            // Act
            var result = controller.Add(inputModel);

            // Assert
            Assert.IsType <BadRequestResult>(result.Result);
        }
示例#4
0
        public async Task Index_ReturnsAViewResult_WithAListOfCPUs()
        {
            // Arrange
            var mockCPUService = new Mock <IService <IRepository <CPU>, CPU> >();

            mockCPUService.Setup(repo => repo.GetAllAsync())
            .ReturnsAsync(GetTestCPUs());
            var controller = new CPUController(mockCPUService.Object);

            // Act
            var result = await controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <CPU> >(
                viewResult.ViewData.Model);

            Assert.Equal(2, model.Count());
        }
    //Function to detect a cursor entering in the trigger area of the Car icon selection
    void OnTriggerEnter2D(Collider2D trigger)
    {
        if (isActive)
        {
            WheelImage = trigger.GetComponentInChildren<Image>();
            WheelImage.color = new Color(1f, 1f, 1f, .5f);
            return;
        }

        isActive = true; //If the cursor enters the icon space the icon becomes active

        TextColorCar = this.GetComponent<Text>(); //Get the instance of the car text and change it to yellow
        TextColorCar.color = Color.yellow;

        CPU = trigger.GetComponent<CPUController>();

        m = trigger.GetComponentInParent<MoveSelector>(); //Make the object that entered the icon space (the trigger) your moveselector target (it will be one of the cursors)
        m.is_this_inside = true;                        // Change the bool variable telling if the cursor is inside the icon area
        t = trigger.gameObject;                        //Set the generic t object to the cursor/trigger
        old = t.transform.parent;                     //Save the current parent of the coin (the cursor) so it can be reassigned to the coin later

        ID = CPU.CoinID;
        AddTempCar();

        if (!CPU.is_coin_cpu || CPU.CoinID == 1)
        {
            ParentPosition = t.transform.localPosition;
        }
    }
 public CPUControllerTests()
 {
     _controller = new CPUController();
 }
 void Awake()
 {
     cpuController1 = new CPUController(1);
     cpuController2 = new CPUController(2);
     pieceHistory = new Stack();
 }