public void DecreaseSFXVolume() { GameObject settingsMenu = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/SettingsMenu")); SettingsMenu settingsMenuScript = settingsMenu.GetComponent <SettingsMenu>(); GameObject sfxVolObj = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/SFXVolObj")); SFXVolObj sfxVolObjScript = sfxVolObj.GetComponent <SFXVolObj>(); float currentSfxVolValue = sfxVolObjScript.getSfxVolValue(); float newSfxVolValue = Random.Range(-40.0f, currentSfxVolValue); settingsMenuScript.SetSFXVolume(newSfxVolValue); float value = settingsMenuScript.GetSFXVolume(); Assert.AreEqual(value, newSfxVolValue); Assert.Less(value, currentSfxVolValue); }