< Summary

Class:HoseHandleMovement
Assembly:Test
File(s):E:/Unity/Unity Project/vr-firefighter-simulator/Assets/Test/HoseHandleMovement.cs
Covered lines:25
Uncovered lines:0
Coverable lines:25
Total lines:55
Line coverage:100% (25 of 25)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:5
Method coverage:100% (5 of 5)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%000100%
Update()0%000100%
getIsTurning()0%000100%
ActivateHandleMovement(...)0%000100%
MoveHoseHandle()0%000100%

File(s)

E:/Unity/Unity Project/vr-firefighter-simulator/Assets/Test/HoseHandleMovement.cs

#LineLine coverage
 1using UnityEngine;
 2
 3public class HoseHandleMovement : MonoBehaviour
 4{
 5    public Vector3 onRotation;
 6    public Vector3 offRotation;
 7    public float rotationSpeed;
 8    private float step;
 9    private Quaternion onRotationQuat;
 10    private Quaternion offRotationQuat;
 11    private Quaternion towardsRotation;
 12    private bool isTurning;
 13
 14
 15    void Awake()
 116    {
 117        this.isTurning = false;
 118        this.step = this.rotationSpeed * Time.deltaTime;
 119        this.onRotationQuat = Quaternion.Euler(this.onRotation);
 120        this.offRotationQuat = Quaternion.Euler(this.offRotation);
 121        this.transform.localRotation = this.offRotationQuat;
 122    }
 23
 24    void Update()
 2212525    {
 3001326        if (isTurning) {
 788827            this.MoveHoseHandle();
 788828        }
 2212529    }
 30
 49431    public bool getIsTurning() {
 49432        return this.isTurning;
 49433    }
 34
 35    public void ActivateHandleMovement(bool turningOn)
 49336    {
 49337        this.isTurning = true;
 49338        this.towardsRotation = turningOn ? this.onRotationQuat : this.offRotationQuat;
 49339    }
 40
 41    private void MoveHoseHandle()
 788842    {
 43        // Rotate from current rot to the quat rotation slowly
 788844        transform.localRotation = Quaternion.RotateTowards(
 45            transform.localRotation,
 46            this.towardsRotation,
 47            this.step
 48        );
 49
 50        // When the turning has finalized, set the flag to false to avoid movement
 838151        if (Quaternion.Angle(transform.localRotation, this.towardsRotation) == 0) {
 49352            this.isTurning = false;
 49353        }
 788854    }
 55}