コード例 #1
0
        public async Task GivenTwoAddressesInDatabase_WhenIUpdate_ItUpdatesTheCorrectAddress()
        {
            using (var context = new DefaultContext(DbContextOptions))
            {
                var addressRepository = new AddressRepository(context);

                var address1 = GetNewAddress();
                var address2 = GetNewAddress();
                address1 = await addressRepository.CreateAsync(address1);

                address2 = await addressRepository.CreateAsync(address2);

                address2.PostalCode = "test update";

                await addressRepository.UpdateAsync(address2);

                var updatedAddress = await context.FindAsync <AddressDb>(address2.Id);

                Assert.AreEqual(address2.PostalCode, updatedAddress.PostalCode);
                Assert.AreEqual(address2.AddressLine1, updatedAddress.AddressLine1);
                Assert.AreEqual(address2.AddressLine2, updatedAddress.AddressLine2);
                Assert.AreEqual(address2.City, updatedAddress.City);
                Assert.AreEqual(address2.Province, updatedAddress.Province);
            }
        }
コード例 #2
0
        public async Task GivenTwoAddressesInDatabase_WhenIUpdate_ItUpdatesTheCorrectAddress()
        {
            using (var context = new DefaultContext(DbContextOptions))
            {
                var venueRepository = new VenueRepository(context);

                var venue1 = GetNewVenue();
                var venue2 = GetNewVenue();
                venue1 = await venueRepository.CreateAsync(venue1);

                venue2 = await venueRepository.CreateAsync(venue2);

                venue2.Name = "test update";

                await venueRepository.UpdateAsync(venue2);

                var updatedVenue = await context.FindAsync <VenueDb>(venue2.Id);

                Assert.AreEqual(venue2.Name, updatedVenue.Name);
                Assert.AreEqual(venue2.Email, updatedVenue.Email);
                Assert.AreEqual(venue2.Phone, updatedVenue.Phone);
                Assert.AreEqual(venue2.Website, updatedVenue.Website);
            }
        }
コード例 #3
0
ファイル: Repository.cs プロジェクト: JL-Code/seckill
 public async Task <T> GetAsync(object id)
 {
     return(await _dbContext.FindAsync <T>(id));
 }