Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void TestJSonSerializtion()
        {
            string nullObj = null;
            string json    = nullObj.ToJsonString();

            Assert.AreEqual("null", json);

            nullObj = json.FromJsonString <string>();
            Assert.AreEqual(null, nullObj);

            IList <Address> addresses = LinqTests.GetQueryCustomerAddressesByCustomerId();

            json = AOP.Invoke(AspectacularTest.TestAspects, () => addresses.ToJsonString());

            Address[] deserializedAddresses = json.FromJsonString <Address[]>();

            Assert.AreEqual(addresses.Count, deserializedAddresses.Length);
            deserializedAddresses.For((addr, i) => Assert.AreEqual(addr[i].ToJsonString(), deserializedAddresses[i].ToJsonString()));

            deserializedAddresses[0].AddressID++;
            Assert.AreNotEqual(addresses[0].ToJsonString(), deserializedAddresses[0].ToJsonString());
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public void TestEmptyAspectCollection()
 {
     AOP.Invoke(null, () => DateTime.IsLeapYear(2012));
 }