Esempio n. 1
0
        public void TestAddRemoveLineItems()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart cart = ShopifyBuy.Client().Cart();

            Dictionary <string, object> data = new Dictionary <string, object>();

            data.Add("id", "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw==");

            ProductVariant variant = new ProductVariant(data);

            cart.LineItems.AddOrUpdate("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==", 33);
            cart.LineItems.AddOrUpdate(variant, 2);
            cart.LineItems.AddOrUpdate("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzczMzY1NjgxMzE=");

            Assert.AreEqual(3, cart.LineItems.All().Count, "has 3 items in cart");
            Assert.AreEqual(33, cart.LineItems.Get("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==").Quantity, "variant 20756129155 Quantity is 33");
            Assert.AreEqual(2, cart.LineItems.Get("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw==").Quantity, "variant 20756129347 Quantity is 2");
            Assert.AreEqual(1, cart.LineItems.Get("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzczMzY1NjgxMzE=").Quantity, "variant 7336568131 Quantity is 1");
            Assert.AreEqual(null, cart.LineItems.Get("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzczMzY1NjgxMzE=").ID, "variant 7336568131 ID is null");

            bool didDelete = cart.LineItems.Delete("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==");

            Assert.AreEqual(2, cart.LineItems.All().Count, "After remove had 2 items in cart");
            Assert.IsTrue(didDelete, "returned true when deleting");

            didDelete = cart.LineItems.Delete("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC9pYW1ub3RyZWFs");
            Assert.IsFalse(didDelete, "returned false when did not delete");
        }
Esempio n. 2
0
        public IEnumerator LoadCollectionsById()
        {
            ShopifyBuy.Init("43b7fef8bd2f27f1d645586b72c9b825", "graphql-many-products.myshopify.com");

            StoppableWaitForTime waiter = Utils.GetWaitQuery();
            var collectionIds           = new List <string>()
            {
                "Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzUzNTk4NjE3OA==",
                "Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzUzOTYyMzQyNg=="
            };

            List <Collection> foundCollections = null;

            ShopifyBuy.Client().collections(
                collectionIds: collectionIds,
                callback: (collections, error) => {
                waiter.Stop();
                foundCollections = collections;
            }
                );

            yield return(waiter);

            Assert.IsTrue(waiter.IsStopped, Utils.MaxQueryMessage);

            for (var i = 0; i < collectionIds.Count; i++)
            {
                Assert.AreEqual(collectionIds[i], foundCollections[i].id());
            }
        }
Esempio n. 3
0
        public void TestLineItemEventsAddUpdateDelete()
        {
            ShopifyBuy.Init(new MockLoader());

            var cart             = ShopifyBuy.Client().Cart();
            var updateTypes      = new List <CartLineItems.LineItemChangeType>();
            var updatedLineItems = new List <CartLineItem>();
            var id1      = "variant-id-1";
            var id2      = "variant-id-2";
            var variant2 = CreateProductVariant(id2);

            cart.LineItems.OnChange += (eventType, lineItem) => {
                updateTypes.Add(eventType);
                updatedLineItems.Add(lineItem);
            };

            cart.LineItems.AddOrUpdate(CreateProductVariant(id1), 33);
            cart.LineItems.AddOrUpdate(variant2, 2);
            cart.LineItems.Delete(id1);
            cart.LineItems.AddOrUpdate(variant2, 55);

            Assert.AreEqual(4, updateTypes.Count);
            Assert.AreEqual(CartLineItems.LineItemChangeType.Add, updateTypes[0]);
            Assert.AreEqual(CartLineItems.LineItemChangeType.Add, updateTypes[1]);
            Assert.AreEqual(CartLineItems.LineItemChangeType.Remove, updateTypes[2]);
            Assert.AreEqual(CartLineItems.LineItemChangeType.Update, updateTypes[3]);

            Assert.AreEqual(id1, updatedLineItems[0].VariantId);
            Assert.AreEqual(id2, updatedLineItems[1].VariantId);
            Assert.AreEqual(id1, updatedLineItems[2].VariantId);
            Assert.AreEqual(id2, updatedLineItems[3].VariantId);
        }
Esempio n. 4
0
        public void TestProductsAll()
        {
            List <Product> products = null;

            ShopifyBuy.Init(new MockLoader());

            ShopifyBuy.Client().products(callback: (p, errors, httpError) => {
                products = p;
                Assert.IsNull(errors);
                Assert.IsNull(httpError);
            });

            Assert.AreEqual(MockLoaderProducts.CountProductsPages * MockLoader.PageSize, products.Count);
            Assert.AreEqual("Product0", products[0].title());
            Assert.AreEqual("Product1", products[1].title());

            Assert.AreEqual(1, products[0].images().edges().Count, "First product has one image");
            Assert.AreEqual(1, products[0].variants().edges().Count, "First product has one variant");
            Assert.AreEqual(1, products[0].collections().edges().Count, "First product has one collection");

            Assert.AreEqual(2 * MockLoader.PageSize, products[1].images().edges().Count, "Second product has 2 pages of images");
            Assert.AreEqual(1, products[1].variants().edges().Count, "Second product has 1 variant");
            Assert.AreEqual(1, products[1].collections().edges().Count, "Second product has one collection");

            Assert.AreEqual(3 * MockLoader.PageSize, products[2].images().edges().Count, "Third page has 3 pages of images");
            Assert.AreEqual(2 * MockLoader.PageSize, products[2].variants().edges().Count, "Third page has 2 pages of variants");
            Assert.AreEqual(1, products[1].collections().edges().Count, "Third product has one collection");
        }
Esempio n. 5
0
        public void ModifyLineItems()
        {
            ShopifyBuy.Init(new MockLoader());

            string productId1 = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==";
            string productId2 = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw==";
            Dictionary <string, string> attributes1 = new Dictionary <string, string>()
            {
                { "fancy", "i am fancy" },
                { "boring", "i am boring" }
            };
            Dictionary <string, string> attributes2 = new Dictionary <string, string>()
            {
                { "animal", "lion" },
                { "spotted", "no" }
            };

            Cart cart = ShopifyBuy.Client().Cart();

            cart.LineItems.AddOrUpdate(productId1, 33);
            cart.LineItems.AddOrUpdate(productId2, 33);

            cart.LineItems.AddOrUpdate(productId1, 100);
            cart.LineItems.AddOrUpdate(productId1, null, attributes1);
            cart.LineItems.AddOrUpdate(productId2, 6, attributes2);

            Assert.AreEqual(100, cart.LineItems.Get(productId1).Quantity, "variant 20756129155 Quantity is 100 after change");
            Assert.AreEqual(6, cart.LineItems.Get(productId2).Quantity, "variant 20756129155 Quantity is 100 after change");
            Assert.AreEqual("i am fancy", cart.LineItems.Get(productId1).CustomAttributes["fancy"]);
            Assert.AreEqual("i am boring", cart.LineItems.Get(productId1).CustomAttributes["boring"]);
            Assert.AreEqual("lion", cart.LineItems.Get(productId2).CustomAttributes["animal"]);
            Assert.AreEqual("no", cart.LineItems.Get(productId2).CustomAttributes["spotted"]);
        }
Esempio n. 6
0
        public void TestCastingLineItems()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart cart = ShopifyBuy.Client().Cart();

            var variantId = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==";
            var variant   = CreateProductVariant(variantId);

            cart.LineItems.AddOrUpdate(variant, 33, new Dictionary <string, string>()
            {
                { "fun", "things" }
            });

            CheckoutLineItemInput       input       = (CheckoutLineItemInput)cart.LineItems.Get(variantId);
            CheckoutLineItemUpdateInput updateInput = (CheckoutLineItemUpdateInput)cart.LineItems.Get(variantId);

            Assert.IsNotNull(input);
            Assert.IsNotNull(updateInput);
            Assert.IsNotNull(input.customAttributes);
            Assert.IsNotNull(updateInput.customAttributes);
            Assert.AreEqual("fun", input.customAttributes[0].key);
            Assert.AreEqual("fun", updateInput.customAttributes[0].key);
            Assert.AreEqual("things", input.customAttributes[0].value);
            Assert.AreEqual("things", updateInput.customAttributes[0].value);
        }
Esempio n. 7
0
        public void TestReset()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart cart = ShopifyBuy.Client().Cart();

            // Add something to the cart.
            cart.LineItems.AddOrUpdate(CreateProductVariant("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ=="), 33);
            cart.LineItems.AddOrUpdate(CreateProductVariant("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw=="), 2);

            Assert.AreEqual(2, cart.LineItems.All().Count, "cart has 2 line items");

            // Start a checkout.
            string       responseURL = null;
            ShopifyError error       = null;

            cart.GetWebCheckoutLink(
                success: (url) => {
                responseURL = url;
            },
                failure: (shopError) => {
                error = shopError;
            }
                );

            Assert.IsNotNull(responseURL, "Was able to generate a web checkout url");
            Assert.IsNull(error, "No error from getting web checkout");
            Assert.IsNotNull(cart.CurrentCheckout, "Cart has a checkout");

            cart.Reset();

            // Verify that we cleared out the line items and checkout.
            Assert.AreEqual(0, cart.LineItems.All().Count, "has 0 items in cart");
            Assert.IsNull(cart.CurrentCheckout, "cart has a null Checkout");
        }
Esempio n. 8
0
        public void TestGetCheckoutLinkWithPoll()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart         cart        = ShopifyBuy.Client().Cart();
            string       responseURL = null;
            ShopifyError error       = null;

            cart.LineItems.AddOrUpdate(CreateProductVariant("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTPOLL=="), 33);
            cart.LineItems.AddOrUpdate(CreateProductVariant("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw=="), 2);

            cart.GetWebCheckoutLink(
                success: (url) => {
                responseURL = url;
            },
                failure: (shopError) => {
                error = shopError;
            }
                );

            Assert.IsNull(error);
            Assert.AreEqual("http://shopify.com/checkout-with-poll-after-poll", responseURL, "weblink was correct");
            Assert.AreEqual("line-item-id1", cart.LineItems.All()[0].ID, "Line item 1 has the correct ID set");
            Assert.AreEqual("line-item-id2", cart.LineItems.All()[1].ID, "Line item 2 has the correct ID set");
        }
Esempio n. 9
0
        public void TestProducts()
        {
            List <Product> products = null;

            ShopifyBuy.Init(new MockLoader());

            ShopifyBuy.Client().products(callback: (p, error, after) => {
                products = p;
                Assert.IsNull(error);
                Assert.AreEqual((DefaultQueries.MaxProductPageSize - 1).ToString(), after);
            });

            Assert.AreEqual(DefaultQueries.MaxProductPageSize, products.Count);
            Assert.AreEqual("Product0", products[0].title());
            Assert.AreEqual("Product1", products[1].title());

            Assert.AreEqual(1, products[0].images().edges().Count, "First product has one image");
            Assert.AreEqual(1, products[0].variants().edges().Count, "First product has one variant");
            Assert.AreEqual(1, products[0].collections().edges().Count, "First product has one collection");

            Assert.AreEqual(2 * MockLoader.PageSize, products[1].images().edges().Count, "Second product has 2 pages of images");
            Assert.AreEqual(1, products[1].variants().edges().Count, "Second product has 1 variant");
            Assert.AreEqual(1, products[1].collections().edges().Count, "Second product has one collection");

            Assert.AreEqual(3 * MockLoader.PageSize, products[2].images().edges().Count, "Third page has 3 pages of images");
            Assert.AreEqual(2 * MockLoader.PageSize, products[2].variants().edges().Count, "Third page has 2 pages of variants");
            Assert.AreEqual(1, products[1].collections().edges().Count, "Third product has one collection");
        }
Esempio n. 10
0
        public void TestUserError()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart         cart        = ShopifyBuy.Client().Cart();
            string       resultUrl   = null;
            ShopifyError resultError = null;

            cart.LineItems.AddOrUpdate(CreateProductVariant("Z2lkOi8vc2hvcGlmeS9Qcm9kdWNFyaWFudC8yMDc1NjEyUserError=="), 1);

            cart.GetWebCheckoutLink(
                success: (url) => {
                resultUrl = url;
            },
                failure: (shopError) => {
                resultError = shopError;
            }
                );

            Assert.IsNull(resultUrl, "no url was returned");
            Assert.IsNotNull(resultError, "returned an errror");
            Assert.AreEqual(ShopifyError.ErrorType.UserError, resultError.Type);
            Assert.AreEqual("There were issues with some of the fields sent. See `cart.UserErrors`", resultError.Description);
            Assert.AreEqual(1, cart.UserErrors.Count);
            Assert.AreEqual("someField", cart.UserErrors[0].field()[0], "fields was correct");
            Assert.AreEqual("bad things happened", cart.UserErrors[0].message(), "messaged was correct");
        }
Esempio n. 11
0
        public void TestUpdateLocale()
        {
            ShopifyBuy.Init("AccessToken", "domain.com");
            Assert.IsNull(ShopifyBuy.Client().Locale);

            ShopifyBuy.Client("domain.com").UpdateLocale("fr");
            Assert.AreEqual("fr", ShopifyBuy.Client("domain.com").Locale);
        }
Esempio n. 12
0
        public void Setup()
        {
            #if (SHOPIFY_TEST)
            ShopifyBuy.Reset();
            #endif

            ShopifyBuy.Init(new MockLoader());
        }
Esempio n. 13
0
        private static ShopifyClient GetClient(string domain, string accessToken)
        {
            if (ShopifyBuy.Client(domain) == null)
            {
                ShopifyBuy.Init(accessToken, domain);
            }

            return(ShopifyBuy.Client(domain));
        }
Esempio n. 14
0
        public void TestGenericQuery()
        {
            ShopifyBuy.Init(new MockLoader());
            string cartWithId = "cartId";

            Assert.IsNotNull(ShopifyBuy.Client().Cart(), "created a cart");
            Assert.IsNotNull(ShopifyBuy.Client().Cart(cartWithId), "created a cart with id");
            Assert.AreNotEqual(ShopifyBuy.Client().Cart(), ShopifyBuy.Client().Cart(cartWithId));
        }
Esempio n. 15
0
 public static void UpdateLocale(string locale, string shopDomain)
 {
     // Updates the locale to fetch translated content for.
     // For more information about supported content and fields, visit
     // https://help.shopify.com/en/api/guides/multi-language/translating-content-api
     if (Initialized)
     {
         ShopifyBuy.Client(shopDomain).UpdateLocale(locale);
     }
 }
Esempio n. 16
0
        public void CannotInitTwiceUsingLoader()
        {
            ShopifyBuy.Init(new MockLoader());
            ShopifyClient client1 = ShopifyBuy.Client("graphql.myshopify.com");

            ShopifyBuy.Init(new MockLoader());
            ShopifyClient client2 = ShopifyBuy.Client("graphql.myshopify.com");

            Assert.IsNotNull(client1);
            Assert.AreSame(client1, client2);
        }
Esempio n. 17
0
        public void CannotInitTwiceUsingDomain()
        {
            ShopifyBuy.Init("AccessToken", "domain2.com");
            ShopifyClient client1 = ShopifyBuy.Client("domain2.com");

            ShopifyBuy.Init("AccessToken", "domain2.com");
            ShopifyClient client2 = ShopifyBuy.Client("domain2.com");

            Assert.IsNotNull(client1);
            Assert.AreSame(client1, client2);
        }
Esempio n. 18
0
        public void TestHttpError()
        {
            ShopifyBuy.Init(new MockLoader());

            // when after is set to 404 MockLoader loader will return an httpError
            ShopifyBuy.Client().products(callback: (p, errors, httpError) => {
                Assert.IsNull(p);
                Assert.IsNull(errors);
                Assert.AreEqual("404 from mock loader", httpError);
            }, first: 250, after: "404");
        }
Esempio n. 19
0
        public static void Init(string accessToken, string shopDomain, string locale = null)
        {
            if (Initialized)
            {
                throw new ShopifyAlreadyInitializedException();
            }

            ShopifyBuy.Init(accessToken, shopDomain, locale);

            Initialized = true;
        }
Esempio n. 20
0
        public void TestGraphQLError()
        {
            ShopifyBuy.Init(new MockLoader());

            // when after is set to 3 MockLoader will return a graphql error
            ShopifyBuy.Client().products(callback: (p, errors, httpError) => {
                Assert.IsNull(p);
                Assert.IsNotNull(errors);
                Assert.AreEqual("GraphQL error from mock loader", errors[0]);
                Assert.IsNull(httpError);
            }, first: 250, after: "666");
        }
Esempio n. 21
0
        public void TestPermalink()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart cart = ShopifyBuy.Client().Cart();

            cart.LineItems.AddOrUpdate("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTE1NQ==", 33);
            cart.LineItems.AddOrUpdate("Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyOTM0Nw==", 2);

            Assert.AreEqual("http://graphql.myshopify.com/cart/20756129155:33,20756129347:2?access_token=1234", cart.GetWebCheckoutLink());
            Assert.AreEqual("http://graphql.myshopify.com/cart/20756129155:33,20756129347:2?access_token=1234&note=i-am-a-note", cart.GetWebCheckoutLink("i-am-a-note"));
        }
Esempio n. 22
0
        public void TestGetCheckoutLinkAfterLineItemModifications()
        {
            ShopifyBuy.Init(new MockLoader());

            Cart         cart              = ShopifyBuy.Client().Cart();
            string       firstResponseURL  = null;
            ShopifyError firstError        = null;
            string       secondResponseURL = null;
            ShopifyError secondError       = null;

            string variantId1 = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyUpdate==";
            string variantId2 = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NjEyDelete==";
            string variantId3 = "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMDc1NTMNewItem==";

            cart.LineItems.AddOrUpdate(CreateProductVariant(variantId1), 33);
            cart.LineItems.AddOrUpdate(CreateProductVariant(variantId2), 2);

            cart.GetWebCheckoutLink(
                success: (url) => {
                firstResponseURL = url;
            },
                failure: (shopError) => {
                firstError = shopError;
            }
                );

            Assert.IsNull(firstError);
            Assert.AreEqual("http://shopify.com/checkout-create-before-update", firstResponseURL, "weblink was correct");
            Assert.AreEqual("line-item-id1", cart.LineItems.All()[0].ID, "Line item 1 has the correct ID set");
            Assert.AreEqual("line-item-id2", cart.LineItems.All()[1].ID, "Line item 2 has the correct ID set");

            // update item
            cart.LineItems.AddOrUpdate(CreateProductVariant(variantId1), 10);
            // delete item
            cart.LineItems.Delete(variantId2);
            // new item
            cart.LineItems.AddOrUpdate(CreateProductVariant(variantId3), 3);

            cart.GetWebCheckoutLink(
                success: (url) => {
                secondResponseURL = url;
            },
                failure: (shopError) => {
                secondError = shopError;
            }
                );

            Assert.IsNull(secondError);
            Assert.AreEqual("http://shopify.com/checkout-create-after-update", secondResponseURL, "weblink was correct after update");
            Assert.AreEqual(2, cart.LineItems.All().Count, "Had two line items after update");
            Assert.AreEqual("line-item-id1", cart.LineItems.All()[0].ID, "Line item 1 has the correct ID set after update");
            Assert.AreEqual("line-item-id3", cart.LineItems.All()[1].ID, "Line item 2 has the correct ID set after update");
        }
Esempio n. 23
0
        private WebCheckoutMessageReceiver CreateMockMessageReceiver(string checkoutId)
        {
            var webCheckoutMessageReceiver = new WebCheckoutMessageReceiver();

            var cartDict = new Dictionary <string, object> {
                { "id", checkoutId }
            };

            webCheckoutMessageReceiver.CurrentCheckout = new Checkout(cartDict);
            webCheckoutMessageReceiver.Client          = ShopifyBuy.Client();

            return(webCheckoutMessageReceiver);
        }
Esempio n. 24
0
        public void TestCollectionsFirst()
        {
            List <Collection> collections = null;

            ShopifyBuy.Init(new MockLoader());
            ShopifyBuy.Client().collections(callback: (c, error, after) => {
                collections = c;
                Assert.IsNull(error);
                Assert.AreEqual((DefaultQueries.MaxCollectionsPageSize - 1).ToString(), after);
            }, first: DefaultQueries.MaxCollectionsPageSize);

            Assert.AreEqual(DefaultQueries.MaxCollectionsPageSize, collections.Count);
        }
        private void Initialize()
        {
            #if (SHOPIFY_TEST)
            ShopifyBuy.Reset();
            #else
            Debug.Log("Warning: You are running tests without defining SHOPIFY_TEST");
            #endif

            ShopifyBuy.Init(AccessToken, ShopDomain);
            Client            = ShopifyBuy.Client();
            CurrentCart       = Client.Cart(CartName);
            CurrentCart.State = new CartState(Client);
        }
Esempio n. 26
0
        public void TestInit()
        {
            Assert.IsNull(ShopifyBuy.Client());
            Assert.IsNull(ShopifyBuy.Client("domain.com"));

            ShopifyBuy.Init("AccessToken", "domain.com");

            Assert.IsNotNull(ShopifyBuy.Client());
            Assert.IsNotNull(ShopifyBuy.Client("domain.com"));
            Assert.AreEqual(ShopifyBuy.Client(), ShopifyBuy.Client("domain.com"));
            Assert.AreEqual("domain.com", ShopifyBuy.Client().Domain);
            Assert.AreEqual("AccessToken", ShopifyBuy.Client().AccessToken);
        }
Esempio n. 27
0
        public void TestProductsFirst()
        {
            List <Product> products = null;

            ShopifyBuy.Init(new MockLoader());

            ShopifyBuy.Client().products(callback: (p, error, after) => {
                products = p;
                Assert.IsNull(error);
                Assert.AreEqual((DefaultQueries.MaxProductPageSize - 1).ToString(), after);
            }, first: DefaultQueries.MaxProductPageSize);

            Assert.AreEqual(DefaultQueries.MaxProductPageSize, products.Count);
        }
Esempio n. 28
0
        void Start()
        {
            ShopifyBuy.Init("351c122017d0f2a957d32ae728ad749c", "graphql.myshopify.com");

            ShopifyBuy.Client().products(
                (products, errors, httpErrors) => {
                IntegrationTest.Assert(null == errors, "No graphql errors");
                IntegrationTest.Assert(null == httpErrors, "No http errors");
                IntegrationTest.Assert(products.Count == 2, "Loaded products");
                IntegrationTest.Assert("Arena Zip Boot" == products[0].title(), "Title product 0: Arena Zip Boot");
                IntegrationTest.Assert("Pin Boot" == products[1].title(), "Title product 1: Pin Boot");

                List <string> aliases = new List <string>()
                {
                    "pico",
                    "pico",
                    "icon",
                    "thumb",
                    "small",
                    "compact",
                    "medium",
                    "large",
                    "grande",
                    "resolution_1024",
                    "resolution_2048"
                };

                foreach (string imageAlias in aliases)
                {
                    IntegrationTest.Assert(null != products[0].images(imageAlias), string.Format("images alias {0} was queried", imageAlias));
                }

                List <ProductVariant> variants = (List <ProductVariant>)products[0].variants();

                foreach (string imageAlias in aliases)
                {
                    // this will throw an exception if not queried
                    variants[0].image(imageAlias);
                }

                // this will throw an exception if not queried
                variants[0].image();

                IntegrationTest.Assert(null != products[0].images(), "images with no alias queried");

                IntegrationTest.Pass();
            },
                "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzk4OTUyODE0NzU=", "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzk4OTUyODQyOTE="
                );
        }
Esempio n. 29
0
        public void TestCollectionsFirst()
        {
            List <Product> products = null;

            ShopifyBuy.Init(new MockLoader());

            ShopifyBuy.Client().products(callback: (p, errors, httpError) => {
                products = p;
                Assert.IsNull(errors);
                Assert.IsNull(null, httpError);
            }, first: 250);

            Assert.AreEqual(250, products.Count);
        }
Esempio n. 30
0
        void Start()
        {
            ShopifyBuy.Init("351c122017d0f2a957d32ae728ad749c", "graphql.myshopify.com");

            ShopifyBuy.Client().products(
                first: 3,
                callback: (products, errors, httpErrors) => {
                IntegrationTest.Assert(null == errors, "No graphql errors");
                IntegrationTest.Assert(null == httpErrors, "No http errors");
                IntegrationTest.Assert(products.Count == 3, "Loaded products");
                IntegrationTest.Assert("Snare Boot" == products[0].title(), "Title product 0: Snare Boot");
                IntegrationTest.Assert("Neptune Boot" == products[1].title(), "Title product 1: Neptune Boot");

                List <string> aliases = new List <string>()
                {
                    "pico",
                    "pico",
                    "icon",
                    "thumb",
                    "small",
                    "compact",
                    "medium",
                    "large",
                    "grande",
                    "resolution_1024",
                    "resolution_2048"
                };

                foreach (string imageAlias in aliases)
                {
                    IntegrationTest.Assert(null != products[0].images(imageAlias), string.Format("images alias {0} was queried", imageAlias));
                }

                List <ProductVariant> variants = (List <ProductVariant>)products[0].variants();

                foreach (string imageAlias in aliases)
                {
                    // this will throw an exception if not queried
                    variants[0].image(imageAlias);
                }

                // this will throw an exception if not queried
                variants[0].image();

                IntegrationTest.Assert(null != products[0].images(), "images with no alias queried");

                IntegrationTest.Pass();
            }
                );
        }