예제 #1
0
        public async Task Update()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            Community community = await communityDao.FindByIdAsync(1);

            string originalName = community.Name;

            community.Name = "New name";
            bool update1 = await communityDao.UpdateCommunityAsync(community);

            Assert.IsTrue(update1);

            community = await communityDao.FindByIdAsync(1);

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

            community.Name = originalName;
            bool update2 = await communityDao.UpdateCommunityAsync(community);

            Assert.IsTrue(update2);

            community = await communityDao.FindByIdAsync(1);

            Assert.AreEqual(community.Name, originalName);
        }
예제 #2
0
        public async Task TestFindAll()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            IEnumerable <Community> communities;

            communities = await communityDao.FindAllAsync();

            Assert.IsTrue(communities.Any());
        }
예제 #3
0
        public async Task TestFindById()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            Community community1 = await communityDao.FindByIdAsync(1);

            Assert.AreEqual(community1.Id, 1);

            Community community5000 = await communityDao.FindByIdAsync(5000);

            Assert.IsNull(community5000);
        }
예제 #4
0
        public async Task Add()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            Community community = new Community(9999, "Test Community", 101);

            bool inserted = await communityDao.AddCommunityAsync(community);

            Assert.IsTrue(inserted);

            community = (await communityDao.FindByNameAsync("Test Community")).FirstOrDefault();

            await communityDao.DeleteCommunityAsync(community);
        }
예제 #5
0
        public async Task TestFindByDistrictId()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            IEnumerable <Community> communities;

            communities = await communityDao.FindByDistrictIdAsync(101);

            Assert.IsTrue(communities.Any());

            communities = await communityDao.FindByDistrictIdAsync(0);

            Assert.IsFalse(communities.Any());
        }
예제 #6
0
        public async Task TestFindByName()
        {
            ICommunityDao communityDao = new AdoCommunityDao(DefaultConnectionFactory.FromConfiguration(configName));

            IEnumerable <Community> communities;

            communities = await communityDao.FindByNameAsync("Freistadt");

            Assert.IsTrue(communities.Any());

            communities = await communityDao.FindByNameAsync("aaa");

            Assert.IsFalse(communities.Any());
        }