Ejemplo n.º 1
0
        public void AcceptsRelativeUri()
        {
            var target = new UriOrFragment("products.html");

            target.IsUri.Should().BeTrue();
            target.IsFragment.Should().BeFalse();
            target.Uri.Should().Be(new Uri("products.html", UriKind.Relative));
        }
Ejemplo n.º 2
0
        public void AcceptsAbsoluteUri()
        {
            var target = new UriOrFragment("http://www.example.com/products.html");

            target.IsUri.Should().BeTrue();
            target.IsFragment.Should().BeFalse();
            target.Uri.Should().Be(new Uri("http://www.example.com/products.html"));
        }
Ejemplo n.º 3
0
        public void AcceptsEmptyFragment()
        {
            var target = new UriOrFragment("#");

            target.IsFragment.Should().BeTrue();
            target.IsUri.Should().BeFalse();
            target.Fragment.Should().Be("#");
        }
Ejemplo n.º 4
0
        public void AcceptsRelativeUriWithFragment()
        {
            var target = new UriOrFragment("products.html#fragment");

            target.IsUri.Should().BeTrue();
            target.IsFragment.Should().BeFalse();

            // Uri.Equals compare fragments on relative URIs.
            target.Uri.Should().Be(new Uri("products.html#fragment", UriKind.Relative));
        }
        private TypeSyntax MakeObjectTypeFromReference(UriOrFragment reference, out string namespaceName)
        {
            string        className     = reference.GetDefinitionName();
            ClassNameHint classNameHint = _hintDictionary?.GetHint <ClassNameHint>(className.ToCamelCase());

            if (classNameHint != null)
            {
                className = classNameHint.ClassName;
            }

            return(MakeNamedType(className, out namespaceName));
        }
Ejemplo n.º 6
0
        public void ThrowsOnInvalidUri()
        {
            UriOrFragment target;
            Action        action = () =>
            {
                // Bad character in port number. It's hard to find a good example of an invalid
                // URI because System.Uri implicitly URL-escapes invalid characters in most
                // locations. But it can't rescue a bad port number.
                target = new UriOrFragment(@"http://www.example.com:80y/products.html");
            };

            action.Should().Throw <UriFormatException>();
        }
Ejemplo n.º 7
0
        public void AcceptsAbsoluteUriWithFragment()
        {
            var target = new UriOrFragment("http://host/products.html#fragment");

            target.IsUri.Should().BeTrue();
            target.IsFragment.Should().BeFalse();

            // Uri.Equals does not compare fragments on absolute URIs...
            target.Uri.Should().Be(new Uri("http://host/products.html", UriKind.Absolute));

            // ... so we'll do it by hand.
            target.Uri.Fragment.Should().Be("#fragment");
        }
Ejemplo n.º 8
0
        public void EqualityTests(EqualityTestCase test)
        {
            UriOrFragment left = test.Left == null
                ? null
                : new UriOrFragment(test.Left);

            UriOrFragment right = test.Right == null
                ? null
                : new UriOrFragment(test.Right);

            left.Equals(right).Should().Be(test.ShouldBeEqual);
            (left == right).Should().Be(test.ShouldBeEqual);
            (left != right).Should().Be(!test.ShouldBeEqual);
        }