コード例 #1
0
        public void GetValuesConverted()
        {
            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" });

            d.GetValues <int>("key").ShouldBe(new[] { 1 });
        }
コード例 #2
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 });
        }