public void Test_UriToStringConverter_throws(string url) { Assert.Throws <UriFormatException>(() => { var log = new Log { Message = url, UpdateTimeTicks = DateTime.Now, Url = new Uri(url), }; DapperExtension.Insert(log); }); }
public void Test_insert_default_value_sql_PK_is_default() { var log = new Log() { CreateTime = DateTime.Now, UpdateTimeTicks = DateTime.Now, Message = nameof(this.Test_insert_default_value_sql_PK_is_default), }; int count = DapperExtension.Insert(log); Assert.Equal(1, count); }
public void Test_insert_default_value_sql_PK_has_value() { var log = new Log() { Identifier = Guid.NewGuid(), CreateTime = DateTime.Now, UpdateTimeTicks = DateTime.Now, Message = nameof(this.Test_insert_default_value_sql_PK_has_value), }; int count = DapperExtension.Insert(log); Assert.Equal(1, count); }
public void Test_DateTimeToTicksConverter() { var log = new Log { Message = nameof(this.Test_DateTimeToTicksConverter), UpdateTimeTicks = DateTime.Now, }; int count = DapperExtension.Insert(log); Assert.Equal(1, count); log = DapperExtension.FirstOrDefault <Log>(); }
public void Test_UriToStringConverter(string url) { var log = new Log { Message = url, UpdateTimeTicks = DateTime.Now, Url = url == null ? null : new Uri(url), }; int count = DapperExtension.Insert(log); Assert.Equal(1, count); log = DapperExtension.FirstOrDefault <Log>(); }
public void Test_BoolToZeroOneConverter() { var course = new Course { Name = "insert", UpdateTime = DateTime.Now, CreateTime = DateTime.Now, IsDeleted = true, }; int count = DapperExtension.Insert(course); Assert.Equal(1, count); course = DapperExtension.FirstOrDefault <Course>(); }
public void Test_entity_has_insert_self_increase_PK() { var student = new Student { Name = "test", Sex = SexEnum.Male, Mobile = "123456789", IsDeleted = true, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; int count = DapperExtension.Insert(student); Assert.Equal(1, count); }
public void Value_converter() { var id = Guid.NewGuid(); var log = new Log() { Identifier = id, CreateTime = DateTime.Now, UpdateTimeTicks = DateTime.Now, Message = nameof(this.Value_converter), }; int count = DapperExtension.Insert(log); log = DapperExtension.Find <Log>(id); Assert.Equal(1, count); Assert.Equal(id, log.Identifier); }
public void TestInsert() { using (var con = new NpgsqlConnection(Infrastructure.PgSql.PgConfig.ConnectionStr)) { var a = new DapperExtension <TUser>(); int time = TimeSpanCalculator.Run(() => { for (int i = 0; i < 1000000; i++) { var user = new TUser() { Id = 4, Name = "dadasd" }; a.Insert(user, con); } }); Console.WriteLine(time.ToString()); } }