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()); }
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()); }
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()); }
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()); }
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); }