示例#1
0
        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
            }
        }
示例#2
0
        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.");
            }
        }
示例#3
0
 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]);
 }