public async Task TestCreateListItem() { //arrange var theList = GetAListForTesting(); await _optionListService.CreateOrUpdateList(theList); var theResult = await _optionListService.GetListByKey(new GetOptionListDto() { Key = TEST_LIST_KEY }); theResult.ShouldNotBeNull(); var theItem = GetAListItemForTesting(theResult.Id); await _optionListItemService.CreateOrUpdateListItem(theItem); await UsingDbContextAsync(async context => { var theNewResult = await _optionListService.GetListByKey(new GetOptionListDto() { Key = TEST_LIST_KEY }); var items = await context.OptionListItems.Include(y => y.OptionList).Where(e => e.OptionListId == theItem.OptionListId).ToListAsync(); items.ShouldNotBeNull(); items.Count.ShouldBeGreaterThanOrEqualTo(1); var theAddedItem = items.FirstOrDefault(x => x.DisplayText == TEST_DISPLAY_TEXT); theAddedItem.AdditionalInfo.ShouldBe(TEST_ADDITIONAL_INFO); theAddedItem.DisplayOrder.ShouldBe(TEST_DISPLAY_ORDER); }); }
private async Task <OptionListViewDto> GetFirstMatchingOptionListByKey(GetOptionListDto input) { if (string.IsNullOrEmpty(input.Key)) { return(null); } return(await _optionListAppService.GetListByKey(input)); }