Example #1
0
        public static void MiscParmsStatic(int intParm, SomeTestClass classParm, ref string refString, out bool outBool)
        {
            Proxy.CurrentLog.LogInformationData("Static method logging test", DateTime.UtcNow);

            refString = string.Format("{0} {1}", intParm, refString);
            outBool = true;
        }
Example #2
0
        [InvariantReturn] // <-testing conflict between stated cacheability and output params.
        public static void MiscParmsStatic(int intParm, SomeTestClass classParm, ref string refString, out bool outBool)
        {
            Proxy.CurrentLog.LogInformationData("Static method logging test", DateTime.UtcNow);

            refString = string.Format("{0} {1}", intParm, refString);
            outBool   = true;
        }
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 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 #5
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 #6
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 #7
0
        public void CallPerfStaticCounterProfile()
        {
            int     parmInt  = 123;
            string  parmStr  = "bogus";
            bool    parmBool = false;
            decimal parmDec  = 1.0m;

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

            long runsPerSec;

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr) non-parallel perf test result: {0} calls/second.", runsPerSec);
        }
Example #8
0
        public void TestStaticLogging()
        {
            Assert.IsNull(Proxy.CurrentLog);

            const int intParm = 456;

            this.IntProp = intParm;
            string        refString = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            bool          outBool   = false;
            SomeTestClass obj       = new SomeTestClass();

            // Example of calling static void method.
            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj, ref refString, out outBool));
            Assert.IsTrue(outBool);
        }
Example #9
0
        public void CallConstStaticPerfCounter()
        {
            const int baseLineMultiThreadConstStaticParmRunsPerSec  = 23000; // 31500; // 33500;
            const int baseLineSingleThreadConstStaticParmRunsPerSec = 8500;  // 9000

            long runsPerSec;

            runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED PARALLEL LOCALVARS CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineMultiThreadConstStaticParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineMultiThreadConstStaticParmRunsPerSec);

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED SEQUENTIAL CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineSingleThreadConstStaticParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineSingleThreadConstStaticParmRunsPerSec);
        }
Example #10
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 #11
0
        public void CallPerfStaticCounter()
        {
            const int baseLineParallelRunsPerSec = 9500; // 10000;
            const int baseLineRunsPerSec         = 3300; // 3500;

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

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

            long runsPerSec;

            runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED PARALLEL VRPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineParallelRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineParallelRunsPerSec);

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED SEQUENTIAL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineRunsPerSec);
        }
Example #12
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 #13
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 #14
0
        public void TestMethodMetadata()
        {
            int intParm = 456;

            this.IntProp = intParm;
            string        refString1 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            bool          outBool    = false;
            SomeTestClass obj1       = new SomeTestClass();

            // Example of calling static void method.
            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj1, ref refString1, out outBool));
            Assert.IsTrue(outBool);

            Thread.Sleep(100);

            intParm = 12456;
            IntProp = intParm;
            string        refString2 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            SomeTestClass obj2       = new SomeTestClass(new DateTime(1999, 5, 3));

            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj2, ref refString2, out outBool));
            Assert.IsTrue(outBool);
        }
Example #15
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 #16
0
        public void TestMethodMetadata()
        {
            int intParm = 456;
            this.IntProp = intParm;
            string refString1 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            bool outBool = false;
            SomeTestClass obj1 = new SomeTestClass();

            // Example of calling static void method.
            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj1, ref refString1, out outBool));
            Assert.IsTrue(outBool);

            Thread.Sleep(100);

            intParm = 12456;
            IntProp = intParm;
            string refString2 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            SomeTestClass obj2 = new SomeTestClass(new DateTime(1999, 5, 3));

            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj2, ref refString2, out outBool));
            Assert.IsTrue(outBool);
        }
Example #17
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 #18
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 #19
0
        public void TestInterceptedException()
        {
            var someCls = new SomeTestClass(new DateTime(2010, 2, 5));

            someCls.GetProxy(TestAspects).Invoke(instance => instance.ThrowFailure());
        }
Example #20
0
        public void TestStaticLogging()
        {
            Assert.IsNull(Proxy.CurrentLog);

            const int intParm = 456;
            this.IntProp = intParm;
            string refString = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            bool outBool = false;
            SomeTestClass obj = new SomeTestClass();

            // Example of calling static void method.
            AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj, ref refString, out outBool));
            Assert.IsTrue(outBool);
        }
Example #21
0
 public void TestInterceptedException()
 {
     var someCls = new SomeTestClass(new DateTime(2010, 2, 5));
     someCls.GetProxy(TestAspects).Invoke(instance => instance.ThrowFailure());
 }