コード例 #1
0
        public void UnmatchedValue_NotNull(object unmatchedValue)
        {
            var ex = new SwitchExpressionException(unmatchedValue);

            Assert.Equal(unmatchedValue, ex.UnmatchedValue);
            Assert.Contains(ex.UnmatchedValue.ToString(), ex.Message);
        }
コード例 #2
0
        public static void Constructor_StringVsObjectArg()
        {
            object message = "exception message";
            var    ex      = new SwitchExpressionException(message as object);

            Assert.NotEqual(message, ex.Message);
            Assert.Same(message, ex.UnmatchedValue);

            ex = new SwitchExpressionException(message as string);

            Assert.Same(message, ex.Message);
            Assert.Null(ex.UnmatchedValue);
        }
コード例 #3
0
        public void Constructors()
        {
            string message = "exception message";
            var    e       = new SwitchExpressionException();

            Assert.NotEmpty(e.Message);
            Assert.Null(e.InnerException);

            e = new SwitchExpressionException(message);
            Assert.Equal(message, e.Message);
            Assert.Null(e.InnerException);

            var inner = new Exception();

            e = new SwitchExpressionException(message, inner);
            Assert.Equal(message, e.Message);
            Assert.Same(inner, e.InnerException);
        }
コード例 #4
0
        public void UnmatchedValue_Null()
        {
            var ex = new SwitchExpressionException((object)null);

            Assert.Null(ex.UnmatchedValue);
        }