Esempio n. 1
0
        public void Should_parse_user_token_from_string()
        {
            var token = RefToken.Parse("client:client1");

            Assert.Equal("client", token.Type);
            Assert.Equal("client1", token.Identifier);
        }
Esempio n. 2
0
        public void Should_parse_user_token_with_colon_in_identifier()
        {
            var token = RefToken.Parse("client:client1:app");

            Assert.Equal("client", token.Type);
            Assert.Equal("client1:app", token.Identifier);
        }
Esempio n. 3
0
        public void Should_parse_token_from_string()
        {
            var token = RefToken.Parse("client:client1");

            Assert.Equal("client1", token.Identifier);
            Assert.True(token.IsClient);
        }
Esempio n. 4
0
        public void Should_parse_token_with_unknown_type()
        {
            var token = RefToken.Parse("user:subject1");

            Assert.Equal("subject1", token.Identifier);
            Assert.True(token.IsUser);
        }
Esempio n. 5
0
        public void Should_serialize_and_deserialize_valid_token()
        {
            var value = RefToken.Parse("client:client1");

            var serialized = value.SerializeAndDeserialize();

            Assert.Equal(value, serialized);
        }
Esempio n. 6
0
        public void Should_provide_correct_hash_codes()
        {
            var token1a = RefToken.Parse("client:client1");
            var token1b = RefToken.Parse("client:client1");
            var token2a = RefToken.Parse("client:client2");

            Assert.Equal(token1a.GetHashCode(), token1b.GetHashCode());

            Assert.NotEqual(token1a.GetHashCode(), token2a.GetHashCode());
        }
Esempio n. 7
0
        public void Should_make_correct_object_equal_comparisons()
        {
            object token1a = RefToken.Parse("client:client1");
            object token1b = RefToken.Parse("client:client1");
            object token2a = RefToken.Parse("client:client2");

            Assert.True(token1a.Equals(token1b));

            Assert.False(token1a.Equals(token2a));
        }
Esempio n. 8
0
        public void Should_make_correct_equal_comparisons()
        {
            var token_type1_id1_a = RefToken.Parse("type1:client1");
            var token_type1_id1_b = RefToken.Parse("type1:client1");

            var token_type2_id1 = RefToken.Parse("type2:client1");
            var token_type1_id2 = RefToken.Parse("type1:client2");

            Assert.Equal(token_type1_id1_a, token_type1_id1_b);
            Assert.Equal(token_type1_id1_a.GetHashCode(), token_type1_id1_b.GetHashCode());
            Assert.True(token_type1_id1_a.Equals((object)token_type1_id1_b));

            Assert.NotEqual(token_type1_id1_a, token_type2_id1);
            Assert.NotEqual(token_type1_id1_a.GetHashCode(), token_type2_id1.GetHashCode());
            Assert.False(token_type1_id1_a.Equals((object)token_type2_id1));

            Assert.NotEqual(token_type1_id1_a, token_type1_id2);
            Assert.NotEqual(token_type1_id1_a.GetHashCode(), token_type1_id2.GetHashCode());
            Assert.False(token_type1_id1_a.Equals((object)token_type1_id2));
        }
Esempio n. 9
0
        public void Should_convert_user_token_to_string()
        {
            var token = RefToken.Parse("client:client1");

            Assert.Equal("client:client1", token.ToString());
        }
Esempio n. 10
0
 public void Should_throw_exception_if_parsing_invalid_input(string input)
 {
     Assert.Throws <ArgumentException>(() => RefToken.Parse(input));
 }
Esempio n. 11
0
 public void Should_serialize_and_deserialize_valid_token()
 {
     RefToken.Parse("client:client1").SerializeAndDeserialize(new RefTokenConverter());
 }
Esempio n. 12
0
 public override object ConvertFrom(ITypeDescriptorContext?context, CultureInfo?culture, object value)
 {
     return(RefToken.Parse((string)value));
 }