private async Task requestProductData()
        {
            try
            {
                var products = await ProductClient.Get();

                if ((products != null) && (products.Entries != null) && products.Entries.Any())
                {
                    inAppPurchase.RequestProductData(products.Entries.Select(p => p.ExternalPID).ToList());
                }
            }
            catch
            {
                //XXX: handle error
            }
        }
Beispiel #2
0
        public async Task GetProduct_ReturnsExpectedProduct()
        {
            var guidRegex         = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
            var expectedProductId = Guid.Parse("E0C2E684-D83F-45C3-A6E5-D62A6F83A0BD");
            var expectedName      = "Test";
            var expectedProduct   = new
            {
                id          = Match.Regex(expectedProductId.ToString(), $"^{guidRegex}$"),
                name        = Match.Type(expectedName),
                description = Match.Type("A product for testing"),
            };

            MockProviderService
            .Given("A Product with expected structure")          // Describe the state the provider needs to setup
            .UponReceiving("a GET request for a single product") // textual description - business case
            .With(new ProviderServiceRequest
            {
                Method = HttpVerb.Get,
                Path   = Match.Regex($"/{expectedProductId}", $"^\\/{guidRegex}$"),
            })
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = 200,
                Headers = new Dictionary <string, object>
                {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = expectedProduct
            });

            var consumer = new ProductClient(MockServerBaseUri);
            var result   = await consumer.Get(expectedProductId);

            Assert.AreEqual(expectedProductId, result.Id);
            Assert.AreEqual(expectedName, result.Name);

            MockProviderService.VerifyInteractions();
        }
 public async Task <ProductResponse> Get(int productId)
 {
     return(await _client.Get(productId));
 }