Exemplo n.º 1
0
        public void Relation_should_be_equal_to_itself()
        {
            // Given
            var rel = new HttpLinkRelation("alternate");

            // When, Then
            rel.ShouldEqual(rel);
        }
Exemplo n.º 2
0
        public void Prefix_and_value_on_iana_relation()
        {
            // Given, When
            var rel = new HttpLinkRelation("alternate");

            // Then
            rel.Prefix.ShouldEqual(HttpLinkRelation.IanaLinkRelationPrefix);
            rel.Value.ShouldEqual("alternate");
        }
Exemplo n.º 3
0
        public void Parse_uri_without_path_throws_format_exception()
        {
            // Given
            const string uri = "http://nancyfx.org/";

            // When
            var exception = Assert.Throws <FormatException>(() => HttpLinkRelation.Parse(uri));

            // Then
            exception.Message.ShouldContain(uri);
        }
Exemplo n.º 4
0
        public void Different_relations_should_not_be_equal()
        {
            // Given
            var first = new HttpLinkRelation("alternate");
            var second = new HttpLinkRelation(new Uri("http://nancyfx.org/rels/"), "home");
            var third = new HttpLinkRelation("http://nancyfx.org/rels/nancy");

            // When, Then
            first.ShouldNotEqual(second);
            second.ShouldNotEqual(third);
        }
Exemplo n.º 5
0
        public void Parse_null_should_throw_argument_null_exception()
        {
            // Given
            const string relation = null;

            // When
            var exception = Assert.Throws <ArgumentNullException>(() => HttpLinkRelation.Parse(relation));

            // Then
            exception.ParamName.ShouldEqual("relation");
        }
Exemplo n.º 6
0
        public void Different_relations_should_not_be_equal()
        {
            // Given
            var first  = new HttpLinkRelation("alternate");
            var second = new HttpLinkRelation(new Uri("http://nancyfx.org/rels/"), "home");
            var third  = new HttpLinkRelation("http://nancyfx.org/rels/nancy");

            // When, Then
            first.ShouldNotEqual(second);
            second.ShouldNotEqual(third);
        }
Exemplo n.º 7
0
        public void Prefix_and_value_on_non_iana_relation_created_from_string()
        {
            // Given
            const string relValue = "http://nancyfx.org/rels/home";

            // When
            var rel = new HttpLinkRelation(relValue);

            // Then
            rel.Prefix.ToString().ShouldEqual("http://nancyfx.org/rels/");
            rel.Value.ShouldEqual("home");
        }
Exemplo n.º 8
0
        public void Prefix_and_value_on_non_iana_relation_created_from_prefix_and_value()
        {
            // Given
            var prefix = new Uri("http://nancyfx.org/rels/");

            // When
            var rel = new HttpLinkRelation(prefix, "home");

            // Then
            rel.Prefix.ShouldEqual(prefix);
            rel.Value.ShouldEqual("home");
        }
Exemplo n.º 9
0
        public void Parse_uri_should_return_link_relation()
        {
            // Given
            const string relation = "http://nancyfx.org/rels/something";

            // When
            var rel = HttpLinkRelation.Parse(relation);

            // Then
            rel.ShouldNotBeNull();
            rel.Prefix.ShouldEqual(new Uri("http://nancyfx.org/rels/"));
            rel.Value.ShouldEqual("something");
        }
Exemplo n.º 10
0
        public void Iana_relations_with_different_casing_and_prefix_should_all_be_equal()
        {
            // Given
            var first = new HttpLinkRelation("AlterNate");
            var second = new HttpLinkRelation("ALTERNATE");
            var third = new HttpLinkRelation("alternate");
            var fourth = new HttpLinkRelation(HttpLinkRelation.IanaLinkRelationPrefix + "alternate");

            // When, Then
            first.ShouldEqual(second);
            second.ShouldEqual(third);
            third.ShouldEqual(fourth);
        }
Exemplo n.º 11
0
        public void Parse_relative_value_should_return_iana_prefixed_link_relation()
        {
            // Given
            const string relation = "alternate";

            // When
            var rel = HttpLinkRelation.Parse(relation);

            // Then
            rel.ShouldNotBeNull();
            rel.Prefix.ShouldEqual(HttpLinkRelation.IanaLinkRelationPrefix);
            rel.Value.ShouldEqual(relation);
        }
Exemplo n.º 12
0
        public void Iana_relations_with_different_casing_and_prefix_should_all_be_equal()
        {
            // Given
            var first  = new HttpLinkRelation("AlterNate");
            var second = new HttpLinkRelation("ALTERNATE");
            var third  = new HttpLinkRelation("alternate");
            var fourth = new HttpLinkRelation(HttpLinkRelation.IanaLinkRelationPrefix + "alternate");

            // When, Then
            first.ShouldEqual(second);
            second.ShouldEqual(third);
            third.ShouldEqual(fourth);
        }
Exemplo n.º 13
0
        public void Different_relations_should_not_have_equal_hash_code()
        {
            // Given
            var first  = new HttpLinkRelation("alternate");
            var second = new HttpLinkRelation(new Uri("http://nancyfx.org/rels/"), "home");
            var third  = new HttpLinkRelation("http://nancyfx.org/rels/nancy");

            // When
            var firstHashCode  = first.GetHashCode();
            var secondHashCode = second.GetHashCode();
            var thirdHashCode  = third.GetHashCode();

            // Then
            firstHashCode.ShouldNotEqual(secondHashCode);
            secondHashCode.ShouldNotEqual(thirdHashCode);
        }
Exemplo n.º 14
0
        public void Different_relations_should_not_have_equal_hash_code()
        {
            // Given
            var first = new HttpLinkRelation("alternate");
            var second = new HttpLinkRelation(new Uri("http://nancyfx.org/rels/"), "home");
            var third = new HttpLinkRelation("http://nancyfx.org/rels/nancy");

            // When
            var firstHashCode = first.GetHashCode();
            var secondHashCode = second.GetHashCode();
            var thirdHashCode = third.GetHashCode();

            // Then
            firstHashCode.ShouldNotEqual(secondHashCode);
            secondHashCode.ShouldNotEqual(thirdHashCode);
        }
Exemplo n.º 15
0
        public void Iana_relations_with_different_casing_and_prefix_should_have_equal_hash_code()
        {
            // Given
            var first  = new HttpLinkRelation("AlterNate");
            var second = new HttpLinkRelation("ALTERNATE");
            var third  = new HttpLinkRelation("alternate");
            var fourth = new HttpLinkRelation(HttpLinkRelation.IanaLinkRelationPrefix + "alternate");

            // When
            var firstHashCode  = first.GetHashCode();
            var secondHashCode = second.GetHashCode();
            var thirdHashCode  = third.GetHashCode();
            var fourthHashCode = fourth.GetHashCode();

            // Then
            firstHashCode.ShouldEqual(secondHashCode);
            secondHashCode.ShouldEqual(thirdHashCode);
            thirdHashCode.ShouldEqual(fourthHashCode);
        }
Exemplo n.º 16
0
        public void Iana_relations_with_different_casing_and_prefix_should_have_equal_hash_code()
        {
            // Given
            var first = new HttpLinkRelation("AlterNate");
            var second = new HttpLinkRelation("ALTERNATE");
            var third = new HttpLinkRelation("alternate");
            var fourth = new HttpLinkRelation(HttpLinkRelation.IanaLinkRelationPrefix + "alternate");

            // When
            var firstHashCode = first.GetHashCode();
            var secondHashCode = second.GetHashCode();
            var thirdHashCode = third.GetHashCode();
            var fourthHashCode = fourth.GetHashCode();

            // Then
            firstHashCode.ShouldEqual(secondHashCode);
            secondHashCode.ShouldEqual(thirdHashCode);
            thirdHashCode.ShouldEqual(fourthHashCode);
        }
Exemplo n.º 17
0
        public void Prefix_and_value_on_iana_relation()
        {
            // Given, When
            var rel = new HttpLinkRelation("alternate");

            // Then
            rel.Prefix.ShouldEqual(HttpLinkRelation.IanaLinkRelationPrefix);
            rel.Value.ShouldEqual("alternate");
        }
Exemplo n.º 18
0
        public void Prefix_and_value_on_non_iana_relation_created_from_string()
        {
            // Given
            const string relValue = "http://nancyfx.org/rels/home";

            // When
            var rel = new HttpLinkRelation(relValue);

            // Then
            rel.Prefix.ToString().ShouldEqual("http://nancyfx.org/rels/");
            rel.Value.ShouldEqual("home");
        }
Exemplo n.º 19
0
        public void Relation_should_be_equal_to_itself()
        {
            // Given
            var rel = new HttpLinkRelation("alternate");

            // When, Then
            rel.ShouldEqual(rel);
        }
Exemplo n.º 20
0
        public void Prefix_and_value_on_non_iana_relation_created_from_prefix_and_value()
        {
            // Given
            var prefix = new Uri("http://nancyfx.org/rels/");

            // When
            var rel = new HttpLinkRelation(prefix, "home");

            // Then
            rel.Prefix.ShouldEqual(prefix);
            rel.Value.ShouldEqual("home");
        }