Esempio n. 1
0
        public void WillReturnUnkownEnum()
        {
            string stringJSON = @"{
                ""shop"": { 
                    ""currencyCode"": ""I AM NOT REAL""
                }
            }";

            Dictionary <string, object> dataJSON = (Dictionary <string, object>)Json.Deserialize(stringJSON);

            QueryRoot response = new QueryRoot(dataJSON);

            Assert.AreEqual(CurrencyCode.UNKNOWN, response.shop().currencyCode());
        }
Esempio n. 2
0
        public void CanDeserializeBasic()
        {
            string stringJSON = @"{
                ""shop"": { 
                    ""name"": ""test-shop""
                }
            }";

            Dictionary <string, object> dataJSON = (Dictionary <string, object>)Json.Deserialize(stringJSON);

            QueryRoot response = new QueryRoot(dataJSON);

            Assert.AreEqual("test-shop", response.shop().name());
        }
Esempio n. 3
0
        public void CanDeserializeEnum()
        {
            string stringJSON = @"{
                ""shop"": { 
                    ""currencyCode"": ""CAD""
                }
            }";

            Dictionary <string, object> dataJSON = (Dictionary <string, object>)Json.Deserialize(stringJSON);

            QueryRoot response = new QueryRoot(dataJSON);

            Assert.AreEqual(CurrencyCode.CAD, response.shop().currencyCode());
        }
Esempio n. 4
0
        public void TestGenericQuery()
        {
            ShopifyBuy.Init(new MockLoader());
            QueryRoot response = null;

            ShopifyBuy.Client().Query(
                (q) => q.shop(s => s
                              .name()
                              ),
                (data, error) => {
                response = data;
                Assert.IsNull(error);
            }
                );

            Assert.AreEqual("this is the test shop yo", response.shop().name());
        }
Esempio n. 5
0
        public void AccessingFieldNotQueriedThrowsException()
        {
            Exception error      = null;
            string    stringJSON = @"{
                ""shop"": { 
                    ""name"": ""test-shop""
                }
            }";

            Dictionary <string, object> dataJSON = (Dictionary <string, object>)Json.Deserialize(stringJSON);

            QueryRoot response = new QueryRoot(dataJSON);

            try {
                response.shop().currencyCode();
            } catch (NoQueryException e) {
                error = e;
            }

            Assert.IsNotNull(error);
            Assert.AreEqual("It looks like you did not query the field `currencyCode`", error.Message);
        }