public override async Task <Guid> AddAsync(Image item, CancellationToken cancellationToken) { using (var dbConnection = Connection()) { dbConnection.Open(); item.Id = Guid.NewGuid(); await dbConnection.ExecuteAsync(_insertQuery, item); // get the new image var me = await FindByIdAsync(item.Id, cancellationToken); // loop keywords and find out what ones we need to make foreach (var keyword in item.Keywords) { await _keywordRepository.LinkImageToKeywordAsync(me.IdKey, keyword, cancellationToken); } return(item.Id); } }
public async Task LinkImageToKeywordAsync(string keyword) { await LoadData(); // get image key var imageKey = await _imageRepository.FindByImageIdAsync("001", CancellationToken.None); //run the test await _keywordRepository.LinkImageToKeywordAsync(imageKey.IdKey, keyword, CancellationToken.None); imageKey = await _imageRepository.FindByImageIdAsync("001", CancellationToken.None); Assert.Contains(imageKey.Keywords, k => k.ToLower() == keyword); }