public void TearDown()
 {
     if (needVerifyDeployer)
     {
         deployerMock.Verify();
     }
 }
        public void TestValidArgument()
        {
            MethodInfo       method   = typeof(ValidationTarget).GetMethod("Save");
            Inventor         inventor = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            ValidationTarget target   = new ValidationTarget();

            object[] args = new object[] { inventor };

            ExpectValidatorRetrieval("required", requiredValidator);
            advice.Before(method, args, target);
            method.Invoke(target, args);

            Assert.AreEqual("NIKOLA TESLA", inventor.Name);

            mockContext.Verify();
        }
示例#3
0
 public void TearDown()
 {
     factoryMock.Verify();
 }
        public void CacheResultOfMethodThatReturnsNull()
        {
            MethodInfo method = new VoidMethod(cacheResultTarget.ReturnsNothing).Method;
            object     expectedReturnValue = null;

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, null);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(expectedReturnValue);

            // check that the null retVal is cached as well - it might be
            // the result of an expensive webservice/database call etc.
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);

            mockInvocation.Verify();
            mockContext.Verify();
        }