Example #1
0
        public void TestNonMethodExpressionInterceptionFailure()
        {
            var someCls = new SomeTestClass();

            // Example of improper calling instance method returning string, by using a non-method-call operator.
            string actual = someCls.GetProxy(TestAspects).Invoke(instance => instance.GetDateString("whatevs") + "123");

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            actual.ToString(CultureInfo.InvariantCulture);
        }
Example #2
0
        public void CallConstPerfCounter()
        {
            const int baseLineConstParmRunsPerSec = 4000;

            var dal = new SomeTestClass();

            long runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(123, "bogus", false, 1m, null)));
            this.TestContext.WriteLine("DoNothing() INSTANCE PROXIED SQUENTIAL CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineConstParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineConstParmRunsPerSec);
        }
Example #3
0
        public void CallConstPerfCounter()
        {
            const int baseLineConstParmRunsPerSec = 4000;

            var dal = new SomeTestClass();

            long runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(123, "bogus", false, 1m, null)));

            this.TestContext.WriteLine("DoNothing() INSTANCE PROXIED SQUENTIAL CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineConstParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineConstParmRunsPerSec);
        }
Example #4
0
        public void TestOne()
        {
            var dal = new SomeTestClass(new DateTime(2010, 2, 5));

            // Example of the most common use case: calling instance GetDateString() method returning string.
            string actual = dal.GetProxy(TestAspects).Invoke(instance => instance.GetDateString("whatevs"));

            Assert.AreEqual("whatevs 2/5/2010 12:00:00 AM", actual);

            // Example of instantiating an IDisposable class, calling its instance method returning string, and disposing of class instance.
            actual = AOP.GetProxy <SomeTestDisposable>(TestAspects).Invoke(dispInstance => dispInstance.Echo("some text"));

            Assert.AreEqual("some text", actual);
        }
Example #5
0
        public void CallPerfCounter()
        {
            const int baseLineSingleThreadRunsPerSec = 2700;
            const int baseLineMultiThreadRunsPerSec  = 9500; // 10000;

            var  dal = new SomeTestClass();
            long runsPerSec;

            int     parmInt  = 123;
            string  parmStr  = "bogus";
            bool    parmBool = false;
            decimal parmDec  = 1.0m;

            int[] arr = { 1, 2, 3, 4, 5 };

            runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("Worst case scenario: DoNothing() INSTANCE PROXIED PARALLEL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineMultiThreadRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineMultiThreadRunsPerSec);

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("DoNothing() INSTANCE PROXIED SEQUENTIAL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineSingleThreadRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineSingleThreadRunsPerSec);
        }
Example #6
0
        public void TestMethodSignatures()
        {
            var obj = new SomeTestClass();

            string username, password;

            username = "******";
            password = "******";
            obj.GetProxy().Invoke(inst => inst.FakeLogin(username, password));

            obj = new SomeTestClass(new DateTime(2010, 11, 5));
            //username = "******";
            //password = "******";
            obj.GetProxy().Invoke(inst => inst.FakeLogin(username, password));

            int index = "Wassup".GetProxy(TestAspects).Invoke(str => str.IndexOf('u'));

            Assert.AreEqual(4, index);
        }
Example #7
0
        public void CallPerfCounter()
        {
            const int baseLineSingleThreadRunsPerSec = 2700;
            const int baseLineMultiThreadRunsPerSec = 9500; // 10000;

            var dal = new SomeTestClass();
            long runsPerSec;

            int parmInt = 123;
            string parmStr = "bogus";
            bool parmBool = false;
            decimal parmDec = 1.0m;
            int[] arr = {1, 2, 3, 4, 5};

            runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("Worst case scenario: DoNothing() INSTANCE PROXIED PARALLEL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineMultiThreadRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineMultiThreadRunsPerSec);

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => dal.GetProxy().Invoke(ctx => ctx.DoNothing(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("DoNothing() INSTANCE PROXIED SEQUENTIAL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineSingleThreadRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineSingleThreadRunsPerSec);
        }
Example #8
0
        public void TestInterceptedException()
        {
            var someCls = new SomeTestClass(new DateTime(2010, 2, 5));

            someCls.GetProxy(TestAspects).Invoke(instance => instance.ThrowFailure());
        }
Example #9
0
 public void TestInterceptedException()
 {
     var someCls = new SomeTestClass(new DateTime(2010, 2, 5));
     someCls.GetProxy(TestAspects).Invoke(instance => instance.ThrowFailure());
 }
Example #10
0
        public void TestOne()
        {
            var dal = new SomeTestClass(new DateTime(2010, 2, 5));

            // Example of the most common use case: calling instance GetDateString() method returning string.
            string actual = dal.GetProxy(TestAspects).Invoke(instance => instance.GetDateString("whatevs"));

            Assert.AreEqual("whatevs 2/5/2010 12:00:00 AM", actual);

            // Example of instantiating an IDisposable class, calling its instance method returning string, and disposing of class instance.
            actual = AOP.GetProxy<SomeTestDisposable>(TestAspects).Invoke(dispInstance => dispInstance.Echo("some text"));

            Assert.AreEqual("some text", actual);
        }
Example #11
0
        public void TestNonMethodExpressionInterceptionFailure()
        {
            var someCls = new SomeTestClass();

            // Example of improper calling instance method returning string, by using a non-method-call operator.
            string actual = someCls.GetProxy(TestAspects).Invoke(instance => instance.GetDateString("whatevs") + "123");
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            actual.ToString(CultureInfo.InvariantCulture);
        }
Example #12
0
        public void TestMethodSignatures()
        {
            var obj = new SomeTestClass();

            string username, password;

            username = "******";
            password = "******";
            obj.GetProxy().Invoke(inst => inst.FakeLogin(username, password));

            obj = new SomeTestClass(new DateTime(2010, 11, 5));
            //username = "******";
            //password = "******";
            obj.GetProxy().Invoke(inst => inst.FakeLogin(username, password));

            int index = "Wassup".GetProxy(TestAspects).Invoke(str => str.IndexOf('u'));
            Assert.AreEqual(4, index);
        }