public void _CreatingProductsFromConfigurationBuilderShouldWork() { var products = ApprienProduct.FromConfigurationBuilder(_builder); var productIds = products.Select(item => item.BaseIAPId).ToList(); Assert.AreEqual(6, products.Length); Assert.Contains(_defaultIAPid, productIds); foreach (var id in _testIAPids) { Assert.Contains(id, productIds); } }
public void SetUp() { _gamePackageName = "dummy.package.name"; _token = "dummy-token"; // Setup products for testing _defaultIAPid = "test-default-id"; // _testIAPids = new List <string>() { "test-1-id", "test-2-id", "test-3-id", "test-4-id", "test-5-id" }; // Setup product lookup _productsLookup = new Dictionary <string, ApprienProduct>(); _productsLookup[_defaultIAPid] = new ApprienProduct(_defaultIAPid, ProductType.Consumable); // Add IAP ids to the catalog _catalog = new ProductCatalog(); _catalog.Add(new ProductCatalogItem() { id = _defaultIAPid, type = ProductType.Consumable }); // Create UnityPurchasing Products _builder = ConfigurationBuilder.Instance(new DummyPurchasingModule()); _builder.AddProduct(_defaultIAPid, ProductType.Consumable); foreach (var id in _testIAPids) { _productsLookup[id] = new ApprienProduct(id, ProductType.Consumable); _catalog.Add(new ProductCatalogItem() { id = id, type = ProductType.Consumable }); _builder.AddProduct(id, ProductType.Consumable); } #if NET_4_6 || NET_STANDARD_2_0 _mockServer = FluentMockServer.Start(); #endif _apprienManager = new ApprienManager( _gamePackageName, ApprienIntegrationType.GooglePlayStore, _token ); }
public IEnumerator FetchingManyProductsShouldSucceed() { SetupMockServer(); var products = new ApprienProduct[] { GetProduct(0), GetProduct(1), GetProduct(2) }; var fetch = _apprienManager.FetchApprienPrices(products, () => { }); while (fetch.MoveNext()) { yield return(null); } for (var i = 0; i < 3; i++) { Assert.AreEqual(_testIAPids[i] + "-variant", products[i].ApprienVariantIAPId); } }
public IEnumerator FetchingProductsWithLongDelayShouldSucceed() { // Configure the SDK timeout to 0.1 second, but make the request take 0.5 seconds // Non-variant products should be fetched _apprienManager.RequestTimeout = 0.1f; SetupMockServer(0.5f); var products = new ApprienProduct[] { GetProduct(0), GetProduct(1), GetProduct(2) }; var fetch = _apprienManager.FetchApprienPrices(products, () => { }); while (fetch.MoveNext()) { yield return(null); } for (var i = 0; i < 3; i++) { Assert.AreEqual(_testIAPids[i], products[i].ApprienVariantIAPId); } }
private void InitializeProducts() { // Create ApprienProducts from the IAP or subscription Catalog var catalogFile = Resources.Load <TextAsset>(_currentTab == TabType.IAPs ? "ApprienIAPProductCatalog" : "ApprienSubscriptionProductCatalog"); var catalog = ProductCatalog.FromTextAsset(catalogFile); _apprienProducts = ApprienProduct.FromIAPCatalog(catalog); // Initialize Unity IAP configuration builder _builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); // Platform specific integration type for the manager. ApprienIntegrationType integrationType; #if UNITY_IOS integrationType = ApprienIntegrationType.AppleAppStore; #else integrationType = ApprienIntegrationType.GooglePlayStore; #endif // Package name. Usually Application.identifier var packageName = Application.identifier; _apprienManager = new ApprienManager( Application.identifier, integrationType, ApprienConnection.Token ); // Add standard IAP ids, so that there is always a fallback if Apprien variants cannot be fetched foreach (var product in _apprienProducts) { _builder.AddProduct(product.BaseIAPId, product.ProductType); } FetchPrices(); }