Example #1
0
        private ArubaAllTypes[] InitializeAllTypes()
        {
            var allTypesList = new ArubaAllTypes[EntitiesCount];

            for (var i = 0; i < EntitiesCount; i++)
            {
                var allTypes = new ArubaAllTypes
                {
                    c2_smallint          = (short)i,
                    c3_tinyint           = (byte)i,
                    c4_bit               = i % 2 == 0,
                    c5_datetime          = new DateTime(1990, i % 12 + 1, i % 28 + 1, i % 12, i % 60, i % 60),
                    c6_smalldatetime     = new DateTime(2010, i % 12 + 1, i % 28 + 1, i % 12, 0, 0),
                    c7_decimal_28_4      = 10 + (decimal)((double)i / 4),
                    c8_numeric_28_4      = -5 + (decimal)((double)i / 8),
                    c9_real              = (float)i / 3,
                    c10_float            = i + (double)i / 3,
                    c11_money            = i + (decimal)((double)i / 5),
                    c12_smallmoney       = i + (decimal)((double)i / 2),
                    c13_varchar_512_     = new string((char)(i + 'a'), i % 8),
                    c14_char_512_        = new string((char)(i + 'a'), 512),
                    c15_text             = new string((char)(i + 'a'), 20 + i),
                    c16_binary_512_      = Enumerable.Repeat <byte>((byte)i, 512).ToArray(),
                    c17_varbinary_512_   = Enumerable.Repeat <byte>((byte)i, 1 + i % 7).ToArray(),
                    c18_image            = Enumerable.Repeat <byte>((byte)i, i + 10).ToArray(),
                    c19_nvarchar_512_    = new string((char)(i + 'a'), i),
                    c20_nchar_512_       = new string((char)(i + 'a'), 512),
                    c21_ntext            = new string((char)(i + 'a'), 20 + i),
                    c22_uniqueidentifier = new Guid(new string((char)((i % 5) + '0'), 32)),
                    c23_bigint           = (long)i * 10,
                    c24_varchar_max_     = new string((char)(i + 'A'), 15 + i % 4),
                    c25_nvarchar_max_    = new string((char)(i + 'A'), 15 + i % 7),
                    c26_varbinary_max_   = Enumerable.Repeat <byte>((byte)i, 15 + i % 8).ToArray(),
                    c27_time             = new TimeSpan(10, i % 60 + 1, i % 60 + i),
                    c28_date             = new DateTime(2000, i % 8 + 1, i % 8 + 1),
                    c29_datetime2        = new DateTime(2012, i % 5 + 1, i % 5 + 1, 1, 2, 3),
                    c30_datetimeoffset   = new DateTimeOffset(new DateTime(2030 + i, 1, 2), new TimeSpan(i % 12, i % 60, 0)),
                    c33_enum             = (ArubaEnum)(i % 4),
                    c34_byteenum         = (ArubaByteEnum)(i % 3),
                    //c35_timestamp
                    c38_shortenum = (ArubaShortEnum)(i % 3)
                };

#if NET452
                allTypes.c31_geography           = DbGeography.FromText(string.Format("POINT ({0}.0 {0}.0)", i % 8), 4326);
                allTypes.c32_geometry            = DbGeometry.FromText(string.Format("POINT (1{0}.0 2{0}.0)", i % 8), 32768);
                allTypes.c36_geometry_linestring = DbGeometry.FromText(string.Format("LINESTRING (1{0} 2{0}, 1{1} 2{0}, 1{1} 2{1}, 1{0} 2{1}, 1{0} 2{0})", i % 5 + 2, i % 5 + 4), 32768);
                allTypes.c37_geometry_polygon    = DbGeometry.FromText(string.Format("POLYGON ((1{1} 2{0}, 1{0} 2{0}, 1{0} 2{1}, 1{1} 2{0}))", i % 5 + 3, i % 5 + 4), 32768);
#endif

                allTypesList[i] = allTypes;
            }

            return(allTypesList);
        }
        private ArubaAllTypes[] InitializeAllTypes()
        {
            var allTypesList = new ArubaAllTypes[EntitiesCount];
            for (var i = 0; i < EntitiesCount; i++)
            {
                var allTypes = new ArubaAllTypes
                {
                    c2_smallint = (short)i,
                    c3_tinyint = (byte)i,
                    c4_bit = i % 2 == 0,
                    c5_datetime = new DateTime(1990, i % 12 + 1, i % 28 + 1, i % 12, i % 60, i % 60),
                    c6_smalldatetime = new DateTime(2010, i % 12 + 1, i % 28 + 1, i % 12, 0, 0),
                    c7_decimal_28_4 = 10 + (decimal)((double)i / 4),
                    c8_numeric_28_4 = -5 + (decimal)((double)i / 8),
                    c9_real = (float)i / 3,
                    c10_float = i + (double)i / 3,
                    c11_money = i + (decimal)((double)i / 5),
                    c12_smallmoney = i + (decimal)((double)i / 2),
                    c13_varchar_512_ = new string((char)(i + 'a'), i % 8),
                    c14_char_512_ = new string((char)(i + 'a'), 512),
                    c15_text = new string((char)(i + 'a'), 20 + i),
                    c16_binary_512_ = Enumerable.Repeat<byte>((byte)i, 512).ToArray(),
                    c17_varbinary_512_ = Enumerable.Repeat<byte>((byte)i, 1 + i % 7).ToArray(),
                    c18_image = Enumerable.Repeat<byte>((byte)i, i + 10).ToArray(),
                    c19_nvarchar_512_ = new string((char)(i + 'a'), i),
                    c20_nchar_512_ = new string((char)(i + 'a'), 512),
                    c21_ntext = new string((char)(i + 'a'), 20 + i),
                    c22_uniqueidentifier = new Guid(new string((char)((i % 5) + '0'), 32)),
                    c23_bigint = (long)i * 10,
                    c24_varchar_max_ = new string((char)(i + 'A'), 15 + i % 4),
                    c25_nvarchar_max_ = new string((char)(i + 'A'), 15 + i % 7),
                    c26_varbinary_max_ = Enumerable.Repeat<byte>((byte)i, 15 + i % 8).ToArray(),
                    c27_time = new TimeSpan(10, i % 60 + 1, i % 60 + i),
                    c28_date = new DateTime(2000, i % 8 + 1, i % 8 + 1),
                    c29_datetime2 = new DateTime(2012, i % 5 + 1, i % 5 + 1, 1, 2, 3),
                    c30_datetimeoffset = new DateTimeOffset(new DateTime(2030 + i, 1, 2), new TimeSpan(i % 12, i % 60, 0)),
                    c31_geography = DbGeography.FromText(string.Format("POINT ({0}.0 {0}.0)", i % 8), 4326),
                    c32_geometry = DbGeometry.FromText(string.Format("POINT (1{0}.0 2{0}.0)", i % 8), 32768),
                    c33_enum = (ArubaEnum)(i % 4),
                    c34_byteenum = (ArubaByteEnum)(i % 3),
                    //c35_timestamp
                    c36_geometry_linestring = DbGeometry.FromText(string.Format("LINESTRING (1{0} 2{0}, 1{1} 2{0}, 1{1} 2{1}, 1{0} 2{1}, 1{0} 2{0})", i % 5 + 2, i % 5 + 4), 32768),
                    c37_geometry_polygon = DbGeometry.FromText(string.Format("POLYGON ((1{1} 2{0}, 1{0} 2{0}, 1{0} 2{1}, 1{1} 2{0}))", i % 5 + 3, i % 5 + 4), 32768),
                    c38_shortenum = (ArubaShortEnum)(i % 3)
                };

                allTypesList[i] = allTypes;
            }

            return allTypesList;
        }
 private static void UpdateArubaAllTypes(ArubaAllTypes allTypes, decimal value)
 {
     allTypes.c7_decimal_28_4 = value;
     allTypes.c8_numeric_28_4 = value;
     allTypes.c11_money = value;
     allTypes.c12_smallmoney = value;
 }
        private static void ValidateSavedValues(ArubaContext context, ArubaAllTypes allTypes, decimal value)
        {
            var saved = context.AllTypes.AsNoTracking().Single(t => t.c1_int == allTypes.c1_int);

            Assert.Equal(value, saved.c7_decimal_28_4);
            Assert.Equal(value, saved.c8_numeric_28_4);
            Assert.Equal(value, saved.c11_money);
            Assert.Equal(value, saved.c12_smallmoney);
        }