コード例 #1
0
        public void Root_Test()
        {
            var root = RouteTemplateNode <object> .CreateRoot();

            Assert.IsNull(root.Parent);
            Assert.AreEqual(string.Empty, root.Value);
            Assert.AreEqual(RouteTemplateNodeType.Literal, root.TemplateNodeType);
        }
コード例 #2
0
        public void Literal_Test(string literalSegment)
        {
            var root = RouteTemplateNode <object> .CreateRoot();

            var child = root.AddChild(literalSegment);

            Assert.AreEqual(root, child.Parent);
            Assert.AreEqual(literalSegment, child.Value);
            Assert.AreEqual(RouteTemplateNodeType.Literal, child.TemplateNodeType);
        }
コード例 #3
0
        public void CatchAll_Test(string catchAllSegment)
        {
            var catchAllValue = catchAllSegment.Substring(2, catchAllSegment.Length - 3);
            var root          = RouteTemplateNode <object> .CreateRoot();

            var child = root.AddChild(catchAllSegment);

            Assert.AreEqual(root, child.Parent);
            Assert.AreEqual(catchAllValue, child.Value);
            Assert.AreEqual(RouteTemplateNodeType.CatchAll, child.TemplateNodeType);
        }
コード例 #4
0
        public void Parameter_Test(string parameterSegment)
        {
            var parameterValue = parameterSegment.Substring(1, parameterSegment.Length - 2);
            var root           = RouteTemplateNode <object> .CreateRoot();

            var child = root.AddChild(parameterSegment);

            Assert.AreEqual(root, child.Parent);
            Assert.AreEqual(parameterValue, child.Value);
            Assert.AreEqual(RouteTemplateNodeType.Parameter, child.TemplateNodeType);
        }
コード例 #5
0
        public void EmptySegment_Must_Throw_Exception()
        {
            var root = RouteTemplateNode <object> .CreateRoot();

            Assert.ThrowsException <ArgumentException>(() => root.AddChild(""));
        }