public void LogsIncludeComments()
        {
            ITargetClass proxy = GetProxy();

            proxy.Method1();

            var logs = string.Join(Environment.NewLine, logTarget.Logs);

            Assert.That(logs, Does.Contain("# Call Section"));
        }
        public void LogsIncludeObjectId()
        {
            ITargetClass proxy = GetProxy();

            proxy.Method1();

            var logs = string.Join(Environment.NewLine, logTarget.Logs);

            Assert.That(logs, Does.Contain("(id=17"));
        }
        public void SingleProxyReturned()
        {
            ITargetClass proxy2  = GetProxy();
            ITargetClass proxy1  = GetProxy(proxy2);
            ITargetClass ignored = new TargetClass();

            proxy1.TryGetSingle(out ignored);

            CollectionAssert.AreEqual(new[]
            {
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.TryGetSingle",
                "YetiCommon.Tests.CastleAspects.TargetClass --> VS: " +
                "YetiCommon.Tests.CastleAspects.TargetClass",
            }, GetNormalizedLogs());
        }
        public void ArrayProxyReturned()
        {
            ITargetClass proxy2 = GetProxy();
            ITargetClass proxy1 = GetProxy(proxy2);

            ITargetClass[] ignored;

            proxy1.TryGetArray(out ignored);

            CollectionAssert.AreEqual(new[]
            {
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.TryGetArray",
                "YetiCommon.Tests.CastleAspects.TargetClass --> VS: " +
                "\\[YetiCommon.Tests.CastleAspects.TargetClass, " +
                "YetiCommon.Tests.CastleAspects.TargetClass]",
            }, GetNormalizedLogs());
        }
        public void ThrowsException()
        {
            ITargetClass proxy = GetProxy();

            Assert.Throws <TestException>(() => proxy.Throw());
            // Calls method3 to ensure the previous exception didn't leave the stack
            // in an inconsistent state.
            proxy.Method3();

            CollectionAssert.AreEqual(new[]
            {
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.Throw",
                "YetiCommon.Tests.CastleAspects.TargetClass --> " +
                "VS: YetiCommon.Tests.CastleAspects.TestException",
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.Method3",
            }, GetNormalizedLogs());
        }
        public void ReturnsNonProxiedValue()
        {
            ITargetClass undecoratedTgt = new TargetClass();
            ITargetClass proxy          = GetProxy(undecoratedTgt);

            ITargetClass[] ignoredArr;
            string         dummyStr;

            proxy.TryGetArrayAndString(out ignoredArr, out dummyStr);

            CollectionAssert.AreEqual(new[]
            {
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.TryGetArrayAndString",
                "YetiCommon.Tests.CastleAspects.TargetClass --> " +
                "VS: \\[{YetiCommon.Tests.CastleAspects.TargetClass}, " +
                "{YetiCommon.Tests.CastleAspects.TargetClass}], " +
                "{System.String} {value=dummy}",
            }, GetNormalizedLogs());
        }
        public void MultipleCalls()
        {
            ITargetClass proxy3 = GetProxy();
            ITargetClass proxy2 = GetProxy(proxy3);
            ITargetClass proxy1 = GetProxy(proxy2);

            proxy1.Method1();

            CollectionAssert.AreEqual(new[]
            {
                "VS -> YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.Method1",
                "YetiCommon.Tests.CastleAspects.TargetClass -> " +
                "YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.Method2 [color=\"red\"]",
                "YetiCommon.Tests.CastleAspects.TargetClass -> " +
                "YetiCommon.Tests.CastleAspects.TargetClass: " +
                "ITargetClass.Method3 [color=\"red\"]",
            }, GetNormalizedLogs());
        }
 public bool TryGetSingle(out ITargetClass single)
 {
     single = other;
     return(true);
 }
 public TargetClass(ITargetClass other = null)
 {
     this.other = other;
 }
 ITargetClass GetProxy(ITargetClass other = null) =>
 proxyGenerator.CreateInterfaceProxyWithTarget <ITargetClass>(
     new TargetClass(other), sequenceAspect);
Пример #11
0
 public static void Execute(ITargetClass target)
 {
     target.Start();
 }