public void Recorded_Method_Model_Test_Recording_Method_Init() { var guid = Guid.NewGuid(); var targetType = TestClass.Method1Entry.TargetType; var methodName = TestClass.Method1Entry.Method.Name; var serTarget = "blah"; var arg = new List <object>() { 2.0, "blah" }; var methodBase = TestClass.Method1Entry.Method; var returnVal = "foo"; var serValue = new SerializedValue(targetType, serTarget); var recordingMethod = new RecordingMethod(guid, serValue, arg, methodBase); recordingMethod.CloseOutMethodWithReturnVal(returnVal); var SUT = new RecordedMethod(recordingMethod); for (int i = 0; i < SUT.Args.Count; i++) { Assert.IsTrue(SUT.Args[i].Equals(arg[i])); } Assert.IsTrue(SUT.Identifier.Equals(guid)); Assert.IsTrue(SUT.InstanceAtExecutionTime.Value.Equals(serTarget)); Assert.IsTrue(SUT.MethodException == null); Assert.IsTrue(SUT.MethodData.MethodName == methodName); Assert.IsTrue(SUT.ReturnVal.GetType().Equals(returnVal.GetType())); Assert.IsTrue(SUT.ReturnVal.Equals(returnVal)); Assert.IsTrue(SUT.SubMethods != null); Assert.IsTrue(SUT.TargetType.Equals(targetType)); }
public void Recorded_Method_Manager_Sub_Method_With_Invalid_Return_Should_Clear_From_Cache() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>(); var serTarget = new SerializedValue(typeof(int), "1"); var args = new List <object>(); var recMethod = new RecordingMethod(Guid.NewGuid(), serTarget, args, TestClass.Method1Entry.Method); var subMethodGuid = Guid.NewGuid(); recMethod.SubMethods.Add(new RecordedSubMethod(subMethodGuid, typeof(int), new List <object>(), typeof(int), TestClass.Method1Entry.Method)); mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(new List <RecordingMethod>() { recMethod }); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(subMethodGuid); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); var procData = TestSubClass.Method1Exit; procData.AddVerificationFailures(new List <VerificationFailure>() { new TypeSerializationFailure(typeof(double)) }); SUT.ProcessCapture(procData); Assert.IsTrue(_methods.Count == 0); }
public RecordedMethod(RecordingMethod finishedMethod) { this.Identifier = finishedMethod.Identifier; this.InstanceAtExecutionTime = finishedMethod.InstanceAtExecutionTime; this.ReturnVal = finishedMethod.ReturnTypeVal; this.TargetType = finishedMethod.TargetType; this.Args = finishedMethod.Args; this.SubMethods = finishedMethod.SubMethods; this.MethodException = finishedMethod.MethodException; this.MethodData = new MethodMetaData(finishedMethod.Method); }
public void Execution_Recorder_Finished_Method_Should_Be_Added_To_DAL() { var _helper = new Mock <IRecordedMethodHelper>(); var _manager = new Mock <IRecordingMethodManager>(); var entry = TestClass.Method1Entry; var serVal = new SerializedValue(entry.TargetType, ""); var recMethod = new RecordingMethod(Guid.NewGuid(), serVal, entry.MethodArgs, entry.Method); recMethod.CloseOutMethodWithReturnVal(TestClass.Method1Exit.ReturnValue); _manager.Setup(x => x.ProcessCapture(It.IsAny <InterceptionProcessingData>())).Raises(f => f.MethodRecordingComplete += null, new MethodRecordingCompleteEventArgs(recMethod)); var SUT = new ExecutionRecorderProcess(_manager.Object, _helper.Object); SUT.ExecuteProcess(TestClass.Method1Entry); _helper.Verify(x => x.AddRecordedMethod(It.IsAny <RecordedMethod>()), Times.Once); }
public void Recorded_Method_Model_Test_Equality_Override() { var guid = Guid.NewGuid(); var targetType = TestClass.Method1Entry.TargetType; var methodName = TestClass.Method1Entry.Method.Name; var serTarget = "blah"; var arg = new List <object>() { 2.0, "blah" }; var methodBase = TestClass.Method1Entry.Method; var returnVal = "foo"; var serValue = new SerializedValue(targetType, serTarget); var recordingMethod = new RecordingMethod(guid, serValue, arg, methodBase); var recordedMethod = new RecordedMethod(recordingMethod); Assert.IsTrue(recordedMethod.Equals(recordedMethod)); Assert.IsFalse(recordedMethod.Equals(new RecordedMethod(Guid.NewGuid()))); Assert.IsTrue(recordedMethod.Equals(new RecordedMethod(guid))); }
// Update is called once per frame void OnGUI() { titleContent = new GUIContent("Recording"); if (ReasonCantRecord() == "") { DisplayRecordingControls(); } else { EditorGUILayout.HelpBox(ReasonCantRecord(), MessageType.Error); } if (recorder == null || recorder.CurrentlyStopped()) { recordingName = EditorGUILayout.TextField("Recording Name", recordingName); RecordingMethod newRecordingMethod = (RecordingMethod)EditorGUILayout.EnumPopup("Recording method", currentRecordingMethod); // Clear recording if method has changed if (newRecordingMethod != currentRecordingMethod) { recorder = null; } currentRecordingMethod = newRecordingMethod; switch (currentRecordingMethod) { case RecordingMethod.Subjects: SetSubjectsSection(); break; case RecordingMethod.Recorder: SetRecorderField(); break; } } }