예제 #1
0
        public async Task StringTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <string>((o, v) => o.String = v,
                                                   null, "", "a", "abc", "a bad ba sdf asdf", "'", "\"",
                                                   "'asdfas'", "\"asdfasd\"", "a's'\"asdf'\"as", "a ' \" a",
                                                   new string('*', 1025), new string('*', 2049), "ÃÇßÑᾆΏ");

                // Split every character between 128 and 0xD7FF into 64
                // strings and try them out.  Disabled only so the test
                // doesn't take forever to run.
                //await context.CheckValues<string>((o, v) => o.String = v,
                //    Enumerable.Zip(
                //        Enumerable.Range(128, 0xD7FF),
                //        Enumerable.Range(128, 0xD7FF),
                //        (index, ch) => Tuple.Create(index, (char)ch))
                //    .GroupBy(pair => pair.Item1 % 64)
                //    .Select(group => new string(group.Select(pair => pair.Item2).ToArray()))
                //    .ToArray());

                await context.ExpectInsertFailure <string>((o, v) => o.String = v,
                                                           "\uDC801\uDC01");
            }
        }
예제 #2
0
 public async Task IntTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues <int>((o, v) => o.Int = v,
                                         0, int.MinValue, int.MaxValue, 1, -1, 2, 120000, -120000);
     }
 }
예제 #3
0
 public async Task UintTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues <uint>((o, v) => o.UInt = v,
                                          0, uint.MinValue, uint.MaxValue, 1, 2, 3, 10, 120000);
     }
 }
예제 #4
0
 public async Task ShortTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues <short>((o, v) => o.Short = v,
                                           0, short.MinValue, short.MaxValue, 1, -1, 2, 10, -10);
     }
 }
예제 #5
0
 public async Task SByteTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues <sbyte>((o, v) => o.SByte = v,
                                           0, sbyte.MinValue, sbyte.MaxValue, 1, -1, 2, -3);
     }
 }
예제 #6
0
 public async Task BooleanTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues((o, v) => o.Bool = v,
                                   true, false);
     }
 }
예제 #7
0
 public async Task UriTest()
 {
     using (DataTypesContext context = await DataTypesContext.Create(this))
     {
         await context.CheckValues <Uri>((o, v) => o.Uri = v,
                                         null,
                                         new Uri("http://www.microsoft.com"),
                                         new Uri("ftp://127.0.0.1"));
     }
 }
예제 #8
0
        public async Task DecimalTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <decimal>((o, v) => o.Decimal = v,
                                                    0.0M, 1.0M, 1.5M, 2.0M, -2.0M, 3.14e12M, -5.2222e-10M);

                context.ExpectSerializationFailure <decimal>((o, v) => o.Decimal = v,
                                                             decimal.MinValue, decimal.MaxValue);
            }
        }
예제 #9
0
        public async Task LongTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <long>((o, v) => o.Long = v,
                                                 0, long.MinValue, 1, -1, 2, 1 >> 40, -(1 >> 40));

                context.ExpectSerializationFailure <long>((o, v) => o.Long = v,
                                                          long.MaxValue);
            }
        }
예제 #10
0
        public async Task ULongTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <ulong>((o, v) => o.ULong = v,
                                                  0, ulong.MinValue, 1, 2, 3, 10, 1 >> 40);

                context.ExpectSerializationFailure <ulong>((o, v) => o.ULong = v,
                                                           ulong.MaxValue);
            }
        }
예제 #11
0
        public async Task CharTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <char>((o, v) => o.Char = v,
                                                 (char)0, (char)1, (char)2, ' ', '\t', '\n', '\b', '?',
                                                 'a', '1', '\u1000', 'Ã', 'Ç', 'ß', 'Ñ', 'ᾆ', 'Ώ');

                await context.ExpectInsertFailure <char>((o, v) => o.Char = v,
                                                         '\uDC01');
            }
        }
예제 #12
0
        public async Task FloatTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <float>((o, v) => o.Float = v,
                                                  0.0f, float.MaxValue, float.MinValue, float.Epsilon, 1.0f,
                                                  1.5f, 2.0f, -2.0f, 3.14e12f, -5.2222e-10f);

                await context.ExpectInsertFailure <float>((o, v) => o.Float = v,
                                                          float.PositiveInfinity, float.NegativeInfinity, float.NaN);
            }
        }
예제 #13
0
        public async Task DoubleTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <double>((o, v) => o.Double = v,
                                                   0.0, double.MaxValue, double.MinValue, double.Epsilon, 1.0,
                                                   1.5, 2.0, -2.0, 3.14e12, -5.2222e-10);

                await context.ExpectInsertFailure <double>((o, v) => o.Double = v,
                                                           double.PositiveInfinity, double.NegativeInfinity, double.NaN);
            }
        }
예제 #14
0
        public async Task DateTimeTest()
        {
            using (DataTypesContext context = await DataTypesContext.Create(this))
            {
                await context.CheckValues <DateTime>((o, v) => o.Date = v,
                                                     DateTime.Now,
                                                     new DateTime(1999, 12, 31, 23, 59, 59),
                                                     new DateTime(2005, 3, 14, 12, 34, 16, DateTimeKind.Local),
                                                     new DateTime(2005, 4, 14, 12, 34, 16, DateTimeKind.Unspecified),
                                                     new DateTime(2005, 5, 14, 12, 34, 16, DateTimeKind.Utc),
                                                     new DateTime(2012, 2, 29, 12, 0, 0, DateTimeKind.Utc)); // Leap Day

                // The following values trigger an assert in the node SQL driver
                // so they're commented out to unblock the test run
                //await context.ExpectInsertFailure<DateTime>((o, v) => o.Date = v,
                //    DateTime.MinValue,
                //    DateTime.MaxValue,
                //    DateTime.MaxValue.AddSeconds(-1),
                //    DateTime.MinValue.AddSeconds(1),
                //    new DateTime(1900, 1, 1));
            }
        }