コード例 #1
0
        public async Task Update()
        {
            IProvinceDao provinceDao = new AdoProvinceDao(DefaultConnectionFactory.FromConfiguration(configName));

            Province province = await provinceDao.FindByIdAsync(1);

            string originalName = province.Name;

            province.Name = "New name";
            bool update1 = await provinceDao.UpdateProvinceAsync(province);

            Assert.IsTrue(update1);

            province = await provinceDao.FindByIdAsync(1);

            Assert.AreEqual(province.Name, "New name");

            province.Name = originalName;
            bool update2 = await provinceDao.UpdateProvinceAsync(province);

            Assert.IsTrue(update2);

            province = await provinceDao.FindByIdAsync(1);

            Assert.AreEqual(province.Name, originalName);
        }
コード例 #2
0
        public async Task FindById()
        {
            IProvinceDao provinceDao = new AdoProvinceDao(DefaultConnectionFactory.FromConfiguration(configName));

            Province province1 = await provinceDao.FindByIdAsync(1);

            Assert.AreEqual(province1.Id, 1);

            Province province5000 = await provinceDao.FindByIdAsync(5000);

            Assert.IsNull(province5000);
        }