public void ClearRunningMethod_Sets_Running_Method_Null() { ShimLibrary.SetRunningMethod(_currentReferenceGuid.ToString()); try { ShimLibrary.AddCallResultToShim(new object[] { }); } catch (Exception) { Assert.Fail("Method should now be running."); } ShimLibrary.ClearRunningMethod(); try { ShimLibrary.AddCallResultToShim(new object[] { }); Assert.Fail("Expected NullReferenceException - no method should be running."); } catch (NullReferenceException) { // do nothing } }
public void SetRunningMethod_Sets_Method_From_Guid() { // At first, a call result should except, as no method is running try { ShimLibrary.AddCallResultToShim(new object[] { }); Assert.Fail("Expected NullReferenceException - no method should be running."); } catch (NullReferenceException) { // do nothing } ShimLibrary.SetRunningMethod(_currentReferenceGuid.ToString()); // Now, it should pass, because a method is running try { ShimLibrary.AddCallResultToShim(new object[] { }); } catch (Exception) { Assert.Fail("Method should now be running."); } }
public void AddCallResultToShim_Adds_Call_Result_With_Parameters() { Assert.IsFalse(_currentShimmedMethod.CallResults.Any()); ShimLibrary.SetRunningMethod(_currentReferenceGuid.ToString()); ShimLibrary.AddCallResultToShim(new object[] { 5 }); Assert.AreEqual(1, _currentShimmedMethod.CallResults.Count); Assert.AreEqual(5, _currentShimmedMethod.CallResults.First().Parameters[0]); }