示例#1
0
        public void GetStringsConverted()
        {
            var d = new DObject();

            Should.Throw <KeyNotFoundException>(() => d.GetStrings("key"));

            d.Set("key", 1);

            Should.Throw <InvalidCastException>(() => d.GetStrings("key"));

            d.Set("key", new[] { 1 });

            d.GetStrings("key").ShouldBe(new[] { "1" });
        }
示例#2
0
        public void GetString()
        {
            var d = new DObject();

            Should.Throw <KeyNotFoundException>(() => d.GetString("key"));

            d.Set("key", "value");

            d.GetString("key").ShouldBe("value");
        }
示例#3
0
        public void GetValue()
        {
            var d = new DObject();

            Should.Throw <KeyNotFoundException>(() => d.GetValue <int>("key"));

            d.Set("key", 1);

            d.GetValue <int>("key").ShouldBe(1);
        }
示例#4
0
        public void GetStrings()
        {
            var d = new DObject();

            Should.Throw <KeyNotFoundException>(() => d.GetStrings("key"));

            d.Set("key", "value");

            Should.Throw <InvalidCastException>(() => d.GetStrings("key"));

            d.Set("key", new[] { "value1" });

            var values = d.GetStrings("key");

            values.ShouldBe(new[] { "value1" });

            values.Add("value2");

            d.GetStrings("key").ShouldBe(new[] { "value1", "value2" });
        }
示例#5
0
        public void GetValues()
        {
            var d = new DObject();

            Should.Throw <KeyNotFoundException>(() => d.GetValues <int>("key"));

            d.Set("key", 1);

            Should.Throw <InvalidCastException>(() => d.GetValues <int>("key"));

            d.Set("key", new[] { 1 });

            var values = d.GetValues <int>("key");

            values.ShouldBe(new[] { 1 });

            values.Add(2);

            d.GetValues <int>("key").ShouldBe(new[] { 1, 2 });
        }