コード例 #1
0
        public void WhenCatalogContainsItem_GetReturnsItem()
        {
            IMyCatalogItem mockItem        = Substitute.For <IMyCatalogItem>();
            MyItemCatalog  systemUnderTest = new MyItemCatalog(new Dictionary <string, IMyCatalogItem>()
            {
                { "SomeId", mockItem }
            });

            Assert.AreEqual(mockItem, systemUnderTest.GetItem("SomeId"));
        }
コード例 #2
0
        public void GetItemCatalog(Callback <IMyItemCatalog> successCallback)
        {
            StartRequest("Getting item catalog");
            GetCatalogItemsRequest request = new GetCatalogItemsRequest();

            PlayFabClientAPI.GetCatalogItems(request, (result) => {
                Dictionary <string, IMyCatalogItem> catalogItems = new Dictionary <string, IMyCatalogItem>();
                foreach (CatalogItem item in result.Catalog)
                {
                    catalogItems.Add(item.ItemId, new MyCatalogItem()
                    {
                        Id = item.ItemId, Tags = item.Tags, CustomData = item.CustomData
                    });
                }

                IMyItemCatalog catalog = new MyItemCatalog(catalogItems);
                successCallback(catalog);

                RequestComplete("GetItemCatalog() complete", LogTypes.Info);   // do this AFTER so that the callback is processed
            },
                                             (error) => { HandleError(error, BackendMessages.GET_CATALOG_FAIL); });
        }
コード例 #3
0
        public void WhenCatalogDoesNotContainItem_GetReturnsNull()
        {
            MyItemCatalog systemUnderTest = new MyItemCatalog(new Dictionary <string, IMyCatalogItem>());

            Assert.IsNull(systemUnderTest.GetItem("SomeId"));
        }