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_Spell_YugiohCard_With_Types_Should_Map_To_SubCategoryIds_Property() { // Arrange var expected = new List <int> { 18 }; var yugiohCard = new YugiohCard { Name = "Black Illusion Ritual", Description = "Amazing card!", CardNumber = "41426869", Property = "Ritual", CardType = "Spell", ImageUrl = "https://vignette.wikia.nocookie.net/yugioh/images/8/82/BlackIllusionRitual-LED2-EN-C-1E.png/revision/latest/scale-to-width-down/300?cb=20180223153750" }; var cardInputModel = new CardInputModel(); // Act var result = SpellCardHelper.MapSubCategoryIds(yugiohCard, cardInputModel, TestData.AllCategories(), TestData.AllSubCategories()); // Assert result.SubCategoryIds.Should().BeEquivalentTo(expected); }