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 Given_A_Valid_Trap_YugiohCard_With_Types_Should_Map_To_SubCategoryIds_Property() { // Arrange var expected = new List <int> { 22 }; var yugiohCard = new YugiohCard { Name = "Call of the Haunted", Description = "Amazing card!", CardNumber = "97077563", Property = "Continuous", CardType = "Trap", ImageUrl = "https://vignette.wikia.nocookie.net/yugioh/images/4/47/CalloftheHaunted-YS18-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180712163539" }; var cardInputModel = new CardInputModel(); // Act var result = TrapCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, TestData.AllCategories(), TestData.AllSubCategories()); // Assert result.SubCategoryIds.Should().BeEquivalentTo(expected); }