Exemplo n.º 1
0
        public void WhenDeserializing_ThenIgnoresNonExistentProperty()
        {
            var serializer = new UsonSerializer();
            var uson       = "foo:bar";

            var json = serializer.Deserialize <QueryOptions>(uson);
        }
Exemplo n.º 2
0
		public void WhenDeserializing_ThenIgnoresNonExistentProperty()
		{
			var serializer = new UsonSerializer();
			var uson = "foo:bar";

			var json = serializer.Deserialize<QueryOptions>(uson);
		}
Exemplo n.º 3
0
		public void WhenDeserializingIntProperty_ThenSucceeds()
		{
			var serializer = new UsonSerializer();

			var value = serializer.Deserialize<Options>("Count:25");

			Assert.Equal(25, value.Count);
		}
Exemplo n.º 4
0
		public void WhenDeserializingMissingProperty_ThenSetsDefaultValue()
		{
			var serializer = new UsonSerializer();

			var value = serializer.Deserialize<Options>("");

			Assert.Equal(10, value.Count);
		}
Exemplo n.º 5
0
		public void WhenDeserializingStringProperty_ThenSucceeds()
		{
			var serializer = new UsonSerializer();

			var value = serializer.Deserialize<Options>("Tag:foo");

			Assert.Equal("foo", value.Tag);
		}
Exemplo n.º 6
0
        public void WhenDeserializingStringProperty_ThenSucceeds()
        {
            var serializer = new UsonSerializer();

            var value = serializer.Deserialize <Options>("Tag:foo");

            Assert.Equal("foo", value.Tag);
        }
Exemplo n.º 7
0
        public void WhenDeserializingIntProperty_ThenSucceeds()
        {
            var serializer = new UsonSerializer();

            var value = serializer.Deserialize <Options>("Count:25");

            Assert.Equal(25, value.Count);
        }
Exemplo n.º 8
0
        public void WhenDeserializingMissingProperty_ThenSetsDefaultValue()
        {
            var serializer = new UsonSerializer();

            var value = serializer.Deserialize <Options>("");

            Assert.Equal(10, value.Count);
        }
Exemplo n.º 9
0
        public void WhenDeserializing_ThenLastSetterWins()
        {
            var serializer = new UsonSerializer();
            var uson       = "tag:wpf owner.id:25 parent.Name:kzu owner.id:10";

            var json = serializer.Deserialize <QueryOptions>(uson);

            Assert.Equal(10, json.Owner.Id);
        }
Exemplo n.º 10
0
		public void WhenDeserializing_ThenLastSetterWins()
		{
			var serializer = new UsonSerializer();
			var uson = "tag:wpf owner.id:25 parent.Name:kzu owner.id:10";

			var json = serializer.Deserialize<QueryOptions>(uson);

			Assert.Equal(10, json.Owner.Id);
		}
Exemplo n.º 11
0
		public void WhenDeserializing_ThenReadsJson()
		{
			var serializer = new UsonSerializer();
			var uson = "tag:wpf owner.id:25 parent.Name:kzu";

			var json = serializer.Deserialize<QueryOptions>(uson);

			Assert.Equal("wpf", json.Tag);
			Assert.Equal(25, json.Owner.Id);
			Assert.Equal("kzu", json.Parent.Name);
		}
Exemplo n.º 12
0
        public void WhenDeserializing_ThenAddsValuesToList()
        {
            var serializer = new UsonSerializer();
            var uson       = "content:foo content:bar";

            var json = serializer.Deserialize <QueryOptions>(uson);

            Assert.Equal(2, json.Content.Count);
            Assert.Equal("foo", json.Content[0]);
            Assert.Equal("bar", json.Content[1]);
        }
Exemplo n.º 13
0
        public void WhenDeserializing_ThenReadsJson()
        {
            var serializer = new UsonSerializer();
            var uson       = "tag:wpf owner.id:25 parent.Name:kzu";

            var json = serializer.Deserialize <QueryOptions>(uson);

            Assert.Equal("wpf", json.Tag);
            Assert.Equal(25, json.Owner.Id);
            Assert.Equal("kzu", json.Parent.Name);
        }
Exemplo n.º 14
0
        public void WhenDeserializingTimespan_ThenParsesValue()
        {
            var serializer = new UsonSerializer();
            var uson       = "timeout:\"00:05:00\"";

            var json = serializer.Deserialize <QueryOptions>(uson);

            json.Timeout = TimeSpan.FromMinutes(5);

            Assert.Equal(TimeSpan.FromMinutes(5), json.Timeout);
        }
Exemplo n.º 15
0
        public void WhenDeserializingWithoutPropertyName_ThenAddsValuesToDefaultProperty()
        {
            var serializer = new UsonSerializer();
            var uson       = "foo bar";

            var json = serializer.Deserialize <QueryOptions>(uson);

            Assert.Equal(2, json.Content.Count);
            Assert.Equal("foo", json.Content[0]);
            Assert.Equal("bar", json.Content[1]);
        }
Exemplo n.º 16
0
		public void WhenDeserializingTimespan_ThenParsesValue()
		{
			var serializer = new UsonSerializer();
			var uson = "timeout:\"00:05:00\"";

			var json = serializer.Deserialize<QueryOptions>(uson);

			json.Timeout = TimeSpan.FromMinutes(5);

			Assert.Equal(TimeSpan.FromMinutes(5), json.Timeout);
		}
Exemplo n.º 17
0
		public void WhenDeserializing_ThenAddsValuesToList()
		{
			var serializer = new UsonSerializer();
			var uson = "content:foo content:bar";

			var json = serializer.Deserialize<QueryOptions>(uson);

			Assert.Equal(2, json.Content.Count);
			Assert.Equal("foo", json.Content[0]);
			Assert.Equal("bar", json.Content[1]);
		}
Exemplo n.º 18
0
		public void WhenDeserializingWithoutPropertyName_ThenAddsValuesToDefaultProperty()
		{
			var serializer = new UsonSerializer();
			var uson = "foo bar";

			var json = serializer.Deserialize<QueryOptions>(uson);

			Assert.Equal(2, json.Content.Count);
			Assert.Equal("foo", json.Content[0]);
			Assert.Equal("bar", json.Content[1]);
		}