Exemplo n.º 1
0
        public void EnsureUrlTypeKindIsCorrect()
        {
            // arrange
            UrlType type = new UrlType();

            // act
            // assert
            Assert.Equal(TypeKind.Scalar, type.Kind);
        }
Exemplo n.º 2
0
        public void ParseLiteral_Invalid_Url_Throws()
        {
            // arrange
            UrlType         type  = new UrlType();
            StringValueNode input = new StringValueNode("$*^domain.test");

            // act
            // assert
            Assert.Throws <ArgumentException>(() => type.ParseLiteral(input));
        }
Exemplo n.º 3
0
        public void IsInstanceOfType_GivenNullValueNode_ReturnsTrue()
        {
            // arrange
            var urlType = new UrlType();

            // act
            var isUrlType = urlType.IsInstanceOfType(new NullValueNode(null));

            // assert
            Assert.True(isUrlType);
        }
Exemplo n.º 4
0
        public void IsInstanceOfType_GivenNull_ThrowsArgumentException()
        {
            // arrange
            var urlType = new UrlType();

            // act
            Action action = () => urlType.IsInstanceOfType(null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Exemplo n.º 5
0
        public void ParseLiteral_Invalid_Url_Throws()
        {
            // arrange
            var type  = new UrlType();
            var input = new StringValueNode("$*^domain.test");

            // act
            // assert
            Assert.Throws <SerializationException>(
                () => type.ParseLiteral(input));
        }
Exemplo n.º 6
0
        public void Serialize_Null()
        {
            // arrange
            UrlType dateType = new UrlType();

            // act
            object serializedValue = dateType.Serialize(null);

            // assert
            Assert.Null(serializedValue);
        }
Exemplo n.º 7
0
        public void Serialize_Url()
        {
            // arrange
            var urlType = new UrlType();
            var uri     = new Uri("http://domain.test/url");

            // act
            object serializedValue = urlType.Serialize(uri);

            // assert
            Assert.Equal(uri.AbsoluteUri, Assert.IsType <string>(serializedValue));
        }
Exemplo n.º 8
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            UrlType       urlType = new UrlType();
            NullValueNode literal = NullValueNode.Default;

            // act
            object value = urlType.ParseLiteral(literal);

            // assert
            Assert.Null(value);
        }
Exemplo n.º 9
0
        public void IsInstanceOfType_GivenUriAsStringValueNode_ReturnsTrue()
        {
            // Arrange
            var urlType = new UrlType();
            var uri     = new Uri("http://domain.test/url");

            // Act
            var isUrlType = urlType.IsInstanceOfType(new StringValueNode(uri.AbsoluteUri));

            // Assert
            Assert.True(isUrlType);
        }
Exemplo n.º 10
0
        public void IsInstanceOfType_GivenInvalidUriAsStringLiteral_False()
        {
            // arrange
            var urlType = new UrlType();

            // act
            var isUrlType = urlType.IsInstanceOfType(
                new StringValueNode("$*^domain.test"));

            // assert
            Assert.False(isUrlType);
        }
Exemplo n.º 11
0
        public void Serialize_Url()
        {
            // arrange
            UrlType urlType = new UrlType();
            Uri     uri     = new Uri("http://domain.test/url");

            // act
            object serializedValue = urlType.Serialize(uri);

            // assert
            Assert.Equal(uri, Assert.IsType <Uri>(serializedValue));
        }
Exemplo n.º 12
0
        public void Serialize_RelativeUrl()
        {
            // arrange
            var urlType = new UrlType();
            var uri     = new Uri("/relative/path", UriKind.Relative);

            // act
            object serializedValue = urlType.Serialize(uri);

            // assert
            Assert.Equal(uri.ToString(), Assert.IsType <string>(serializedValue));
        }
Exemplo n.º 13
0
        public void IsInstanceOfType_GivenNonUrlValueNode_ReturnsFalse()
        {
            // arrange
            var urlType  = new UrlType();
            var intValue = new IntValueNode(1);

            // act
            var isUrlType = urlType.IsInstanceOfType(intValue);

            // assert
            Assert.False(isUrlType);
        }
Exemplo n.º 14
0
        public void Serialize_Url()
        {
            // arrange
            UrlType urlType       = new UrlType();
            Uri     uri           = new Uri("http://domain.test/url");
            string  expectedValue = uri.AbsoluteUri;

            // act
            string serializedValue = (string)urlType.Serialize(uri);

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }
Exemplo n.º 15
0
        public void ParseLiteral_RelativeUrl()
        {
            // arrange
            var urlType  = new UrlType();
            var expected = new Uri("/relative/path", UriKind.Relative);
            var literal  = new StringValueNode($"{expected}");

            // act
            var actual = (Uri)urlType.ParseLiteral(literal);

            // Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 16
0
        public void ParseLiteral_StringValueNode()
        {
            // arrange
            var urlType  = new UrlType();
            var expected = new Uri("http://domain.test/url");
            var literal  = new StringValueNode(expected.AbsoluteUri);

            // act
            var actual = (Uri)urlType.ParseLiteral(literal);

            // assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 17
0
        public void ParseValue_Encoded()
        {
            // arrange
            UrlType urlType = new UrlType();
            Uri     uri     = new Uri("http://domain.test/ä+😄?q=a/α");
            string  expectedLiteralValue = uri.AbsoluteUri;

            // act
            StringValueNode stringLiteral =
                (StringValueNode)urlType.ParseValue(uri);

            // assert
            Assert.Equal(expectedLiteralValue, stringLiteral.Value);
        }
Exemplo n.º 18
0
        public void ParseValue_Url()
        {
            // arrange
            var    urlType = new UrlType();
            var    uri     = new Uri("http://domain.test/url");
            string expectedLiteralValue = uri.AbsoluteUri;

            // act
            var stringLiteral =
                (StringValueNode)urlType.ParseValue(uri);

            // assert
            Assert.Equal(expectedLiteralValue, stringLiteral.Value);
        }