Esempio n. 1
0
 public void can_read_single_nullable_enum()
 {
     var stubDataReader = new StubDataReader
     {
         Names  = new[] { "ID" },
         Types  = new[] { typeof(int) },
         Values = new object[] { 1 },
     };
     var val = stubDataReader.Single <TestEnum?>();
 }
Esempio n. 2
0
 public void can_read_single_nullable_primative_type()
 {
     var stubDataReader = new StubDataReader
     {
         Names  = new[] { "ID" },
         Types  = new[] { typeof(long) },
         Values = new object[] { 1L },
     };
     var val = stubDataReader.Single <long?>();
 }
Esempio n. 3
0
        public void can_read_single()
        {
            var reader = new StubDataReader
            {
                Names  = new[] { "ID" },
                Types  = new[] { typeof(long) },
                Values = new object[] { 1L },
            };

            reader.Single <long>();
        }
Esempio n. 4
0
        public void cannot_read_single_when_more_than_one_row()
        {
            var stubDataReader = new StubDataReader
            {
                Names       = new [] { "ORDER_ID" },
                Types       = new [] { typeof(int) },
                Values      = new object[] { 1 },
                RecordCount = 2,
            };

            Assert.Throws <InvalidOperationException>(() => { stubDataReader.Single <int>(); });
        }
Esempio n. 5
0
        public void cannot_read_default_value_for_single()
        {
            var stubDataReader = new StubDataReader
            {
                Names       = new[] { "ORDER_ID" },
                Types       = new[] { typeof(int) },
                Values      = new object[] { 1 },
                RecordCount = 0,
            };

            Assert.Throws <InvalidOperationException>(() => { stubDataReader.Single <int>(); });
        }
Esempio n. 6
0
        public void can_read_single_nullable_via_explicit_operator()
        {
            var stubDataReader = new StubDataReader
            {
                Names  = new[] { "VALUE" },
                Types  = new[] { typeof(int) },
                Values = new object[] { 1 },
            };
            var val = stubDataReader.Single <Id <Order>?>();

            Assert.AreEqual((Id <Order>) 1, val.Value);
        }
Esempio n. 7
0
        public void can_read_into_struct()
        {
            var stubDataReader = new StubDataReader
            {
                Names  = new[] { "VALUE" },
                Types  = new[] { typeof(long) },
                Values = new object[] { 1L },
            };
            var val = stubDataReader.Single <TestStruct <long> >();

            Assert.AreEqual(1L, val.Value);
        }
Esempio n. 8
0
        public void can_read_single_object_containing_guid()
        {
            var g = Guid.NewGuid();
            var stubDataReader = new StubDataReader
            {
                Names  = new[] { "VALUE" },
                Types  = new[] { g.GetType() },
                Values = new object[] { g },
            };
            var read = stubDataReader.Single <Guid?>();

            Assert.AreEqual(g, read.Value);
        }
Esempio n. 9
0
        public void can_read_single_DateTimeOffset()
        {
            var dt             = DateTimeOffset.Now;
            var stubDataReader = new StubDataReader
            {
                Names  = new[] { "ID" },
                Types  = new[] { dt.GetType() },
                Values = new object[] { dt },
            };
            var read = stubDataReader.Single <DateTimeOffset>();

            Assert.AreEqual(dt, read);
        }
Esempio n. 10
0
        public void can_read_single_guid()
        {
            var g = Guid.NewGuid();
            var stubDataReader = new StubDataReader
            {
                Names  = new[] { "ID" },
                Types  = new[] { g.GetType() },
                Values = new object[] { g },
            };
            var read = stubDataReader.Single <Guid>();

            Assert.AreEqual(g, read);
        }