コード例 #1
0
        public void WithMultipleReturns(int returnAt)
        {
            // This is compiled such that each return statement essentially becomes
            // a branch to the very last ret statement
            TestMessages.Record("VoidMethodWithMultipleReturns: Body - 0");

            if (returnAt == 1)
            {
                return;
            }

            TestMessages.Record("VoidMethodWithMultipleReturns: Body - 1");

            if (returnAt == 2)
            {
                return;
            }

            TestMessages.Record("VoidMethodWithMultipleReturns: Body - 2");

            if (returnAt == 3)
            {
                return;
            }

            TestMessages.Record("VoidMethodWithMultipleReturns: Body - 3");
        }
コード例 #2
0
        public void ConditionallyThrowingInvalidOperationException(bool shouldThrow)
        {
            TestMessages.Record("VoidMethodConditionallyThrowingInvalidOperationException: Body");
            if (shouldThrow)
            {
                throw new InvalidOperationException("Ooops");
            }

            TestMessages.Record("VoidMethodConditionallyThrowingInvalidOperationException: Body2");
        }
コード例 #3
0
        public int MultipleReturnValuesButWithEmbeddedThrow(int returnAt)
        {
            TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 0");

            if (returnAt == 1)
            {
                return(42);
            }

            TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 1");

            if (returnAt == 2)
            {
                throw new InvalidOperationException("Ooops");
            }

            TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 2");

            return(164);
        }
コード例 #4
0
        public int MultipleReturns(int input)
        {
            TestMessages.Record("MultipleReturns: Body - 0");

            if (input == 1)
            {
                return(7);
            }

            TestMessages.Record("MultipleReturns: Body - 1");

            if (input == 2)
            {
                return(14);
            }

            TestMessages.Record("MultipleReturns: Body - 2");

            return(input == 3 ? 21 : 28);
        }
コード例 #5
0
        public void MultipleReturnValuesButEndingWithThrow(int returnAt)
        {
            TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 0");

            if (returnAt == 1)
            {
                return;
            }

            TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 1");

            if (returnAt == 2)
            {
                return;
            }

            TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 2");

            throw new InvalidOperationException("Ooops");
        }
コード例 #6
0
        public void WithMultipleReturnsAndExceptions(int actAt, bool shouldThrow)
        {
            TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 0");

            if (actAt == 1)
            {
                if (shouldThrow)
                {
                    throw new InvalidOperationException("Throwing at 1");
                }
                return;
            }

            TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 1");

            if (actAt == 2)
            {
                if (shouldThrow)
                {
                    throw new InvalidOperationException("Throwing at 2");
                }
                return;
            }

            TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 2");

            if (actAt == 3)
            {
                if (shouldThrow)
                {
                    throw new InvalidOperationException("Throwing at 3");
                }
                return;
            }

            TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 3");
        }
コード例 #7
0
 public SimpleConstructor()
 {
     TestMessages.Record("InterceptingConstructors+SimpleConstructor: .ctor");
 }
コード例 #8
0
 public int ReturnsNumber()
 {
     TestMessages.Record("ReturnsNumber: Body");
     return(42);
 }
コード例 #9
0
 public string ReturnsString()
 {
     TestMessages.Record("ReturnsString: Body");
     return("hello world");
 }
コード例 #10
0
 public void OnEntry(MethodBase method)
 {
     TestMessages.Record(string.Format("OnEntry: {0}", method.DeclaringType.FullName + "." + method.Name));
 }
コード例 #11
0
 public void OnException(MethodBase method, Exception exception)
 {
     TestMessages.Record(string.Format("OnException: {0} - {1}: {2}", method.DeclaringType.FullName + "." + method.Name, exception.GetType(), exception.Message));
 }
コード例 #12
0
 public void WithoutArgs()
 {
     TestMessages.Record("VoidMethodWithoutArgs: Body");
 }
コード例 #13
0
 public void ThrowingInvalidOperationException()
 {
     TestMessages.Record("VoidMethodThrowingInvalidOperationException: Body");
     throw new InvalidOperationException("Ooops");
 }
コード例 #14
0
 public static string ToTitleCase(this string value)
 {
     TestMessages.Record("ToTitleCase: In extension method");
     return(new CultureInfo("en-GB", false).TextInfo.ToTitleCase(value));
 }