public async Task Given_An_AllAttributes_Query_Should_Return_All_Attributes() { // Arrange const int expected = 2; _attributeService.AllAttributes().Returns(new List <Attribute> { new Attribute(), new Attribute() }); // Act var result = await _sut.Handle(new AllAttributesQuery(), CancellationToken.None); // Assert result.Should().HaveCount(expected); }
private async Task <CardInputModel> MapToCardInputModel(YugiohCard yugiohCard, CardInputModel cardInputModel, ICollection <Category> categories, ICollection <SubCategory> subCategories) { CardHelper.MapBasicCardInformation(yugiohCard, cardInputModel); CardHelper.MapCardImageUrl(yugiohCard, cardInputModel); if (cardInputModel.CardType.Equals(YgoCardType.Spell)) { SpellCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, categories, subCategories); } else if (cardInputModel.CardType.Equals(YgoCardType.Trap)) { TrapCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, categories, subCategories); } else { ICollection <Type> types = await _typeService.AllTypes(); ICollection <Attribute> attributes = await _attributeService.AllAttributes(); ICollection <LinkArrow> linkArrows = await _linkArrowService.AllLinkArrows(); var monsterCategory = categories.Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase)); var monsterSubCategories = subCategories.Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id); MonsterCardHelper.MapMonsterCard(yugiohCard, cardInputModel, attributes, monsterSubCategories, types, linkArrows); } return(cardInputModel); }
public void SetUp() { _categoryService = Substitute.For <ICategoryService>(); _subCategoryService = Substitute.For <ISubCategoryService>(); _typeService = Substitute.For <ITypeService>(); _attributeService = Substitute.For <IAttributeService>(); _linkArrowService = Substitute.For <ILinkArrowService>(); _categoryService.AllCategories().Returns(TestData.AllCategories()); _subCategoryService.AllSubCategories().Returns(TestData.AllSubCategories()); _typeService.AllTypes().Returns(TestData.AllTypes()); _attributeService.AllAttributes().Returns(TestData.AllAttributes()); _linkArrowService.AllLinkArrows().Returns(TestData.AllLinkArrows()); _sut = new CardCommandMapper ( _categoryService, _subCategoryService, _typeService, _attributeService, _linkArrowService ); }
public async Task <IEnumerable <AttributeOutputModel> > Handle(AllAttributesQuery request, CancellationToken cancellationToken) { var attributes = await _attributeService.AllAttributes(); return(attributes.MapToOutputModels()); }