Пример #1
0
        public void OptionalUri()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Null(d.GetURI());
            Assert.Equal(new Uri("http://example.net/"), d.GetURI(new Uri("http://example.net/")));
        }
Пример #2
0
        public void OptionalEnum()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal(default(StringComparison), d.GetEnum());
            Assert.Equal(StringComparison.OrdinalIgnoreCase, d.GetEnum(StringComparison.OrdinalIgnoreCase));
        }
Пример #3
0
        public void OptionalUInt64()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal(0UL, d.GetUInt64());
            Assert.Equal(49UL, d.GetUInt64(49));
        }
Пример #4
0
        public void OptionalString()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Null(d.GetString());
            Assert.Equal("something else", d.GetString("something else"));
        }
Пример #5
0
        public void OptionalSByte()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal(0, d.GetSByte());
            Assert.Equal(49, d.GetSByte(49));
        }
Пример #6
0
        public void OptionalChar()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal('\0', d.GetChar());
            Assert.Equal('!', d.GetChar('!'));
        }
Пример #7
0
        public void OptionalDecimal()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal(0m, d.GetDecimal());
            Assert.Equal(49m, d.GetDecimal(49m));
        }
Пример #8
0
        public void OptionalDateTime()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.Equal(default(DateTime), d.GetDate());
            Assert.Equal(new DateTime(9876, 5, 4, 3, 2, 1), d.GetDate(new DateTime(9876, 5, 4, 3, 2, 1)));
        }
Пример #9
0
        public void OptionalBoolean()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();

            Assert.False(d.GetBoolean());
            Assert.True(d.GetBoolean(true));
            Assert.False(d.GetBoolean(false));
        }
Пример #10
0
        public void OptionalStruct()
        {
            dynamic d = new TypeWithOptionalsWithoutDefaults();
            KeyValuePair <int, string> kvp = d.GetStruct();

            Assert.Equal(0, kvp.Key);
            Assert.Null(kvp.Value);
            kvp = d.GetStruct(new KeyValuePair <int, string>(23, "value"));
            Assert.Equal(23, kvp.Key);
            Assert.Equal("value", kvp.Value);
        }