public void Recorded_Method_Manager_Instance_Verifier_Fail_Should_Still_Add_Sub_Method() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var serTarget = new SerializedValue(typeof(int), "1"); var args = new List <object>(); var _methods = new List <RecordingMethod>() { new RecordingMethod(Guid.NewGuid(), serTarget, args, TestClass.Method1Entry.Method) }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_methods[0].Identifier); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); var procData = TestSubClass.Method1Entry; procData.AddVerificationFailures(new List <VerificationFailure>() { new TypeSerializationFailure(typeof(double)) }); SUT.ProcessCapture(procData); Assert.IsTrue(_methods.Count == 1); Assert.IsTrue(_methods[0].SubMethods.Count == 1); }
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 void Recorded_Method_Manager_Test_Thread_Id_Is_Used_On_Execution_Stack() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>(); mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.ProcessCapture(TestClass.Method1Entry); mockStack.Verify(x => x.ProcessEntry(_defaultThreadId, It.IsAny <Guid>()), Times.AtLeastOnce); }
public void Recorded_Method_Manager_Verify_Execution_Stack_Is_Added_To() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>() { TestClass.Method1EntryRecording }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_methods[0].Identifier); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.ProcessCapture(TestSubClass.Method1Entry); mockStack.Verify(x => x.ProcessEntry(_defaultThreadId, It.IsAny <Guid>()), Times.Once); }
public void Recorded_Method_Manager_Handles_Recursion_Method_Adding() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>() { TestClass.Method1EntryRecording }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_methods.FirstOrDefault().Identifier); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.MethodRecordingComplete += SUT_MethodRecordingComplete; SUT.ProcessCapture(TestSubClass.Method1Entry); Assert.IsTrue(_methodCompleteEventRaised == false); }
public void Recorded_Method_Manager_Instace_Verifier_Fail_Should_Not_Call_Serializer() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>(); mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); var procData = TestClass.Method1Entry; procData.AddVerificationFailures(new List <VerificationFailure>() { new TypeSerializationFailure(typeof(double)) }); SUT.ProcessCapture(procData); _defaultSerializer.Verify(x => x.Serialize(It.IsAny <object>()), Times.Never); }
public void Recorded_Method_Manager_Closes_Method_With_Stack_Depth_GT_1() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>() { TestClass.Method1EntryRecording, TestSubClass.Method1EntryRecording }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_methods[1].Identifier); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.MethodRecordingComplete += SUT_MethodRecordingComplete; SUT.ProcessCapture(TestSubClass.Method1Exit); Assert.IsTrue(_methodCompleteEventRaised == true); }
public void Recorded_Method_Manager_Instance_Verifier_Fail_Should_Not_Create_New_Exec_Method() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>(); mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_emptySentinel); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); var procData = TestClass.Method1Exit; procData.AddVerificationFailures(new List <VerificationFailure>() { new TypeSerializationFailure(typeof(double)) }); SUT.ProcessCapture(procData); Assert.IsTrue(_methods.Count == 0); }
public void Recorded_Method_Manager_Method_Exception_Raises_Complete_Event() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var serTarget = new SerializedValue(typeof(int), "1"); var args = new List <object>(); var _methods = new List <RecordingMethod>() { new RecordingMethod(Guid.NewGuid(), serTarget, args, TestClass.Method1Entry.Method) }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(_methods.FirstOrDefault().Identifier); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.MethodRecordingComplete += SUT_MethodRecordingComplete; SUT.ProcessCapture(TestClass.Method1Exception); Assert.IsTrue(_methodCompleteEventRaised == true); }
public void Recorded_Method_Manager_Verify_Completed_Method_Is_Returned() { var mockCache = new Mock <IExecutionCache>(); var mockStack = new Mock <IExecutionStack>(); var _methods = new List <RecordingMethod>() { TestClass.Method1EntryRecording, TestSubClass.Method1EntryRecording }; mockCache.Setup(x => x.GetMethods(It.IsAny <int>())).Returns(_methods); var closeOutMethodId = _methods[1].Identifier; mockStack.Setup(x => x.ExecutingGuid(It.IsAny <int>())).Returns(closeOutMethodId); var SUT = new RecordingMethodManager(mockCache.Object, _defaultThreadProvider.Object, mockStack.Object, _defaultSerializer.Object); SUT.MethodRecordingComplete += SUT_MethodRecordingComplete; SUT.ProcessCapture(TestSubClass.Method1Exit); Assert.IsTrue(_eventArgs.Method.Identifier == closeOutMethodId); }