Пример #1
0
        public void GetStoreCastType_ReturnsCorrectType()
        {
            var data = new Dictionary <Type, string>()
            {
                { typeof(bool), SqlColumnType.Numeric },
                { typeof(DateTime), SqlColumnType.Numeric },
                { typeof(decimal), SqlColumnType.Numeric },
                { typeof(int), SqlColumnType.Integer },
                { typeof(uint), SqlColumnType.Integer },
                { typeof(long), SqlColumnType.Integer },
                { typeof(ulong), SqlColumnType.Integer },
                { typeof(short), SqlColumnType.Integer },
                { typeof(ushort), SqlColumnType.Integer },
                { typeof(byte), SqlColumnType.Integer },
                { typeof(sbyte), SqlColumnType.Integer },
                { typeof(float), SqlColumnType.Real },
                { typeof(double), SqlColumnType.Real },
                { typeof(string), SqlColumnType.Text },
                { typeof(Guid), SqlColumnType.Text },
                { typeof(byte[]), SqlColumnType.Text },
                { typeof(Uri), SqlColumnType.Text },
                { typeof(TimeSpan), SqlColumnType.Text }
            };

            foreach (var item in data)
            {
                Assert.Equal(SqlHelpers.GetStoreCastType(item.Key), item.Value);
            }
        }
Пример #2
0
        public void GetStoreCastType_Throws_WhenTypeIsNotSupported()
        {
            var types = new[] { typeof(SqlHelper_Test), typeof(DateTimeOffset) };

            foreach (Type type in types)
            {
                var ex = Assert.Throws <NotSupportedException>(() => SqlHelpers.GetStoreCastType(type));
                Assert.Equal("Value of type '" + type.Name + "' is not supported.", ex.Message);
            }
        }