public void RowAssociationAccess() { var logger = new Performancer(); using (var context = CreateContext(MethodBase.GetCurrentMethod().Name)) { logger.Log("Connected to database."); CreateUser(context); logger.Log("Created user."); var user = context.Users.Select().ExecuteFetch(); logger.Log("Fetched user."); Logs[] logs = new Logs[200]; for (int i = 0; i < logs.Length; i++) { logs[i] = new Logs() { text = "This is log item " + i.ToString(), Users_rowid = user.rowid }; } context.Logs.Insert(logs); logger.Log("Inserted logs."); var logs_assoc = user.Logs; logger.Log("Accessed user/log association."); Assert.NotNull(logs_assoc); Assert.Equal("This is log item 0", logs_assoc[0].text); Assert.Equal("This is log item 1", logs_assoc[1].text); logger.OutputTraceLog(); } }
public void RowBaseTypesStoreAndRetrieve() { var logger = new Performancer(); using (var context = CreateContext(MethodBase.GetCurrentMethod().Name)) { logger.Log("Connected to database."); byte[] initial_byte_array = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 254, 243, 252, 251, 250, 249, 248, 247, 246, 245 }; var date_time = DateTimeOffset.Now; int ch = (int)'D'; string t = date_time.ToString(); context.AllTypes.Insert(new AllTypes() { db_bool = true, db_byte = 157, db_byte_array = initial_byte_array, db_date_time = date_time, db_decimal = 3456789.986543M, db_double = 12345.54321D, db_float = 123.321F, db_int16 = 32767, db_int32 = 2147483647, db_int64 = 9223372036854775807, db_string = "Database String With \nNewline\nSpecial Chars: ♥♦♣♠", db_enum = TestEnum.SecondEnumValue }); logger.Log("Inserted new row into db."); var all_types = context.AllTypes.Select().ExecuteFetch(); logger.Log("Retrieved new row from db."); Assert.Equal(true, all_types.db_bool); Assert.Equal(157, all_types.db_byte.Value); // Test the contents of the byte array. Assert.Equal(initial_byte_array.Length, all_types.db_byte_array.Length); for (int i = 0; i < initial_byte_array.Length; i++) { Assert.Equal(initial_byte_array[i], all_types.db_byte_array[i]); } Assert.Equal(date_time, all_types.db_date_time); Assert.Equal(3456789.986543M, all_types.db_decimal.Value); Assert.Equal(12345.54321D, all_types.db_double.Value); Assert.Equal(123.321F, all_types.db_float.Value); Assert.Equal(32767, all_types.db_int16.Value); Assert.Equal(2147483647, all_types.db_int32.Value); Assert.Equal(9223372036854775807, all_types.db_int64.Value); Assert.Equal(TestEnum.SecondEnumValue, all_types.db_enum); Assert.Equal("Database String With \nNewline\nSpecial Chars: ♥♦♣♠", all_types.db_string); logger.Log("Completed tests."); logger.OutputTraceLog(); } }