public async Task NullVariantItem() { var mock = SetupGetSheetService(new List <IList <object> > { new List <object> { "Internal ID", "Name", "Catalog", "Source", "Image" }, new List <object> { "5036", "aqua tile flooring", "For sale", "Nook's Cranny", @"=IMAGE(""https://acnhcdn.com/latest/FtrIcon/RoomTexFloorTile01.png"")" }, }); var service = new CommunitySheetIngestService(new List <IGetSheetService> { mock.Object }); var actual = await service.Ingest(); actual.Should().HaveCount(1); actual.Should().Contain(new Item( ItemId.From("5036"), ItemName.From("aqua tile flooring"), CatalogueStatus.FOR_SALE, Source.NOOKS_CRANNY, Image.From("https://acnhcdn.com/latest/FtrIcon/RoomTexFloorTile01.png"), null )); }
public void FilterByManyCatalogueStatus() { var items = new List <Item> { new Item( ItemId.From("1"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), null ), new Item( ItemId.From("1"), ItemName.From("formal paper"), CatalogueStatus.FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), null ) }; var service = new InMemoryItemService(items); var actual = service.List( new ItemFilter("", new List <CatalogueStatus> { CatalogueStatus.FOR_SALE, CatalogueStatus.NOT_FOR_SALE }, new List <Source>()), new PageCursor(100, 0) ); actual.Count.Should().Be(2); actual.Items.Should().HaveCount(2); actual.Items.Should().Contain(items); }
public async Task VariantItem() { var mock = SetupGetSheetService(new List <IList <object> > { new List <object> { "Internal ID", "Name", "Catalog", "Source", "Image", "Variant ID", "Variation" }, new List <object> { "3821", "air circulator", "For sale", "Nook's Cranny", @"=IMAGE(""https://acnhcdn.com/latest/FtrIcon/FtrCirculator_Remake_2_0.png"")", "2_0", "Pink" }, }); var service = new CommunitySheetIngestService(new List <IGetSheetService> { mock.Object }); var actual = await service.Ingest(); actual.Should().HaveCount(1); actual.Should().Contain(new Item( ItemId.From("3821"), ItemName.From("air circulator"), CatalogueStatus.FOR_SALE, Source.NOOKS_CRANNY, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrCirculator_Remake_2_0.png"), new ItemVariant( ItemVariantId.From("2_0"), ItemVariantName.From("Pink") ) )); }
public async Task AlbumImage() { var mock = SetupGetSheetService(new List <IList <object> > { new List <object> { "Internal ID", "Name", "Catalog", "Source", "Album Image" }, new List <object> { "3200", "K.K. Fusion", "For sale", "K.K. concert; Nook Shopping Catalog", @"=IMAGE(""https://acnhcdn.com/latest/Audio/mjk_Fusion.png"")" }, }); var service = new CommunitySheetIngestService(new List <IGetSheetService> { mock.Object }); var actual = await service.Ingest(); actual.Should().HaveCount(1); actual.Should().Contain(new Item( ItemId.From("3200"), ItemName.From("K.K. Fusion"), CatalogueStatus.FOR_SALE, Source.UNKNOWN, Image.From("https://acnhcdn.com/latest/Audio/mjk_Fusion.png"), null )); }
public async Task NonVariantItem() { var mock = SetupGetSheetService(new List <IList <object> > { new List <object> { "Internal ID", "Name", "Catalog", "Source", "Image", "Variant ID", "Variantion" }, new List <object> { "1317", "anatomical model", "For sale", "Nook's Cranny", @"=IMAGE(""https://acnhcdn.com/latest/FtrIcon/FtrAnatomicalmodel.png"")", "NA", "NA" }, }); var service = new CommunitySheetIngestService(new List <IGetSheetService> { mock.Object }); var actual = await service.Ingest(); actual.Should().HaveCount(1); actual.Should().Contain(new Item( ItemId.From("1317"), ItemName.From("anatomical model"), CatalogueStatus.FOR_SALE, Source.NOOKS_CRANNY, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAnatomicalmodel.png"), null )); }
public void Serialize() { var actual = JsonSerializer.Serialize(new Item( ItemId.From("383"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), new ItemVariant( ItemVariantId.From("0_0"), ItemVariantName.From("Natural") ) )); actual.Should().Be(@"{""id"":""383"",""name"":""acoustic guitar"",""catalogueStatus"":1,""source"":1,""image"":""https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"",""variant"":{""id"":""0_0"",""name"":""Natural""}}"); }
public void ItemWithoutVariant() { var item = new Item( ItemId.From("1"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), null ); var items = new List <Item> { item }; var service = new InMemoryItemService(items); var actual = service.Get(item.Id, null); actual.Should().Be(item); }
private Item?ToItem(IDictionary <string, Object> row) { try { return(new Item( ItemId.From(row["Internal ID"].ToString()), ItemName.From(row["Name"].ToString()), CatalogueStatusFromString(row["Catalog"].ToString()), SourceFromString(row["Source"].ToString()), GetImage(row), GetVariant(row) )); } catch (Exception e) { Console.WriteLine(JsonSerializer.Serialize(row)); Console.WriteLine(e); return(null); } }
public void ItemNotExists() { var item = new Item( ItemId.From("1"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), new ItemVariant( ItemVariantId.From("1_0"), ItemVariantName.From("Natural") ) ); var items = new List <Item> { item }; var service = new InMemoryItemService(items); FluentActions .Invoking(() => service.Get(ItemId.From("1234"), null)) .Should().Throw <InvalidOperationException>(); }
public void ItemWithVariants() { var item1 = new Item( ItemId.From("1"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), new ItemVariant( ItemVariantId.From("0_0"), ItemVariantName.From("Natural") ) ); var item2 = new Item( ItemId.From("1"), ItemName.From("acoustic guitar"), CatalogueStatus.NOT_FOR_SALE, Source.CRAFTING, Image.From("https://acnhcdn.com/latest/FtrIcon/FtrAcorsticguitar_Remake_0_0.png"), new ItemVariant( ItemVariantId.From("1_0"), ItemVariantName.From("Natural") ) ); var items = new List <Item> { item1, item2 }; var service = new InMemoryItemService(items); var actual = service.GroupByVariants(); actual.Should().ContainKeys(item1.Id); actual[item1.Id].Should().HaveCount(2); actual[item1.Id][0].Id.Should().Be(item1.Id); actual[item1.Id][0].Id.Should().Be(item2.Id); }