Пример #1
0
        public void WhenDeserializing_ThenIgnoresNonExistentProperty()
        {
            var serializer = new UsonSerializer();
            var uson       = "foo:bar";

            var json = serializer.Deserialize <QueryOptions>(uson);
        }
Пример #2
0
		public void WhenDeserializing_ThenIgnoresNonExistentProperty()
		{
			var serializer = new UsonSerializer();
			var uson = "foo:bar";

			var json = serializer.Deserialize<QueryOptions>(uson);
		}
Пример #3
0
		public void WhenDeserializingIntProperty_ThenSucceeds()
		{
			var serializer = new UsonSerializer();

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

			Assert.Equal(25, value.Count);
		}
Пример #4
0
		public void WhenDeserializingMissingProperty_ThenSetsDefaultValue()
		{
			var serializer = new UsonSerializer();

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

			Assert.Equal(10, value.Count);
		}
Пример #5
0
		public void WhenDeserializingStringProperty_ThenSucceeds()
		{
			var serializer = new UsonSerializer();

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

			Assert.Equal("foo", value.Tag);
		}
Пример #6
0
        public void WhenDeserializingStringProperty_ThenSucceeds()
        {
            var serializer = new UsonSerializer();

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

            Assert.Equal("foo", value.Tag);
        }
Пример #7
0
        public void WhenDeserializingIntProperty_ThenSucceeds()
        {
            var serializer = new UsonSerializer();

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

            Assert.Equal(25, value.Count);
        }
Пример #8
0
        public void WhenDeserializingMissingProperty_ThenSetsDefaultValue()
        {
            var serializer = new UsonSerializer();

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

            Assert.Equal(10, value.Count);
        }
Пример #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);
        }
Пример #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);
		}
Пример #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);
		}
Пример #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]);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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]);
        }
Пример #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);
		}
Пример #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]);
		}
Пример #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]);
		}