コード例 #1
0
 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);
     });
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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>();
        }
コード例 #5
0
        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>();
        }
コード例 #6
0
        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>();
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: UnitTest1.cs プロジェクト: DiggingSteve/DotNetCore
 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());
     }
 }