Esempio n. 1
0
        public void Insert()
        {
            using (var dbContext = this.GlobalServiceProvider.GetRequiredService <CommonDbContext <CommonDbContextTestsInfo> >())
            {
                var testsInfo = new CommonDbContextTestsInfo
                {
                    Name       = Guid.NewGuid().ToString(),
                    Type       = InfoType.Black,
                    CreateTime = DateTime.Now
                };

                var id = dbContext.ExecuteScalar <int>(nameof(Insert), testsInfo);

                Assert.True(id > 0);
            }
        }
Esempio n. 2
0
        public void SelectById()
        {
            using (var dbContext = this.GlobalServiceProvider.GetRequiredService <CommonDbContext <CommonDbContextTestsInfo> >())
            {
                var testsInfo = new CommonDbContextTestsInfo
                {
                    Name       = Guid.NewGuid().ToString(),
                    Type       = InfoType.Black,
                    CreateTime = DateTime.Now
                };

                var id = dbContext.ExecuteScalar <int>(nameof(Insert), testsInfo);

                var selectInfo = dbContext.Query <DbContextTestInfo>(nameof(SelectById), new { id }).SingleOrDefault();

                Assert.NotNull(selectInfo);
                Assert.Equal(selectInfo.Name, testsInfo.Name);
            }
        }