< Summary

Class:HoseController
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/HoseController.cs
Covered lines:49
Uncovered lines:0
Coverable lines:49
Total lines:86
Line coverage:100% (49 of 49)
Covered branches:0
Total branches:0
Covered methods:9
Total methods:9
Method coverage:100% (9 of 9)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HoseController()0%000100%
Awake()0%000100%
Update()0%000100%
IsValidChange()0%000100%
HandleHoseAudio()0%000100%
StartHoseAudio()0%000100%
EndHoseAudio()0%000100%
HandleHoseWaterWithDelay()0%000100%
HandleHoseWater()0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/HoseController.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3
 4public class HoseController : MonoBehaviour
 5{
 6    public HoseHandleMovement hoseHandle;
 7    public ParticleSystem hoseWaterPs;
 8    public AudioSource audioSource;
 9    public AudioClip hoseAudioStart;
 10    public AudioClip hoseAudioDuring;
 11    public float waterDelayTime;
 12    public float changeStateInterval;
 13
 214    private float lastChangeState = 10f;
 15    private bool hoseIsOn;
 16
 17    // Start is called before the first frame update
 18    void Awake()
 119    {
 120        this.hoseHandle = GameObject.FindGameObjectWithTag("HoseHandle").GetComponent<HoseHandleMovement>();
 121        this.audioSource = this.GetComponent<AudioSource>();
 122        this.hoseIsOn = false;
 123        this.HandleHoseWater();
 124    }
 25
 26    // Update is called once per frame
 27    void Update()
 355428    {
 355429        if (this.IsValidChange() && !this.hoseHandle.getIsTurning() && ActionMapper.GetDevicesTrigger())
 3530        {
 3531            this.hoseIsOn = !this.hoseIsOn;
 3532            this.hoseHandle.ActivateHandleMovement(this.hoseIsOn);
 3533            this.HandleHoseAudio();
 3534            StartCoroutine(this.HandleHoseWaterWithDelay(this.waterDelayTime));
 3535            this.lastChangeState = 0f;
 3536        }
 355437        this.lastChangeState += Time.deltaTime;
 355438    }
 39
 40    bool IsValidChange()
 355441    {
 355442        return this.lastChangeState >= this.changeStateInterval;
 355443    }
 44
 45    void HandleHoseAudio()
 3546    {
 5347        if (this.hoseIsOn) {
 1848            StartCoroutine(this.StartHoseAudio());
 3549        } else {
 1750            this.EndHoseAudio();
 1751        }
 3552    }
 53
 54    IEnumerator StartHoseAudio()
 1855    {
 1856        this.audioSource.clip = this.hoseAudioStart;
 1857        this.audioSource.Play();
 1858        yield return new WaitForSeconds(this.audioSource.clip.length);
 1759        this.audioSource.clip = this.hoseAudioDuring;
 1760        this.audioSource.Play();
 1761    }
 62
 63    void EndHoseAudio()
 1764    {
 1765        StartCoroutine(AudioUtils.FadeOut(this.audioSource, 0.7f));
 1766    }
 67
 68    IEnumerator HandleHoseWaterWithDelay(float delayTime)
 3569    {
 70        //Wait for the specified delay time before continuing.
 3571        yield return new WaitForSeconds(delayTime);
 72
 73        // Turn water on or off
 3574        this.HandleHoseWater();
 3575    }
 76
 77    void HandleHoseWater()
 3678    {
 5479        if (this.hoseIsOn) {
 1880            this.hoseWaterPs.Play();
 3681        } else {
 1882            this.hoseWaterPs.Stop();
 1883        }
 3684    }
 85
 86}