using System; using NUnit.Framework; using UnityEditor.Recorder; namespace UnityEngine.Recorder.Tests { class RecorderControllerTests { [Test] public void PrepareRecording_WithNullSettings_ThrowsException() { var recorderController = new RecorderController(null); var ex = Assert.Throws(() => recorderController.PrepareRecording()); Assert.IsTrue(ex.Message.Contains("Can start recording without prefs")); } [Test] public void StartRecording_WithEmptySettings_ShouldNotStartRecording() { var settings = ScriptableObject.CreateInstance(); var recorderController = new RecorderController(settings); recorderController.PrepareRecording(); Assert.IsFalse(recorderController.StartRecording()); Assert.IsFalse(recorderController.IsRecording()); Object.DestroyImmediate(settings); } [Test] public void StartAndStopRecording_WithValidSettings_ShouldStartThenStopRecording() { var settings = ScriptableObject.CreateInstance(); var imageRecorder = ScriptableObject.CreateInstance(); settings.AddRecorderSettings(imageRecorder); var recorderController = new RecorderController(settings); recorderController.PrepareRecording(); Assert.IsTrue(recorderController.StartRecording()); Assert.IsTrue(recorderController.IsRecording()); recorderController.StopRecording(); Assert.IsFalse(recorderController.IsRecording()); Object.DestroyImmediate(imageRecorder); Object.DestroyImmediate(settings); } } }