public void ApiResponseCleanerFetchJsonArrayWithEmptyLinkedEntitiesSucceeds() { const string expected = @"[{""BankAccounts"":[]}]"; string clean = ApiResponseCleaner.GetJsonArray(JsonFileReader.GetJsonFromFile("ApiResponse_Json_Array_WithEmptyLinkedEntities.txt")); Assert.AreEqual(expected, clean); }
public void EntityConverter_ConvertJsonToDynamicObject_WithIncorrectJson_Fails() { string json = JsonFileReader.GetJsonFromFile("Response_Json_Object_GLAccount_WithCorruptJson.txt"); dynamic glaccountObject = _entityConverter.ConvertJsonToDynamicObject(json); Assert.AreEqual("D", (string)glaccountObject.BalanceSide); Assert.AreEqual("W", (string)glaccountObject.BalanceType); }
public void EntityConverter_ConvertJsonToObjectList_WithParsedJson_Succeeds() { string jsonarray = JsonFileReader.GetJsonFromFile("Response_Json_Array_Account.txt"); List <Account> accounts = _entityConverter.ConvertJsonArrayToObjectList <Account>(jsonarray); if (accounts.Count != 2) { throw new Exception("The count of the list isn't equal to the actual list"); } }
public void EntityConverter_ConvertLinkedEntityJsonToObject_Succeeds() { string json = ApiResponseCleaner.GetJsonObject(JsonFileReader.GetJsonFromFile("Response_Json_Object_SalesInvoice.txt")); var converter = new EntityConverter(); var invoice = converter.ConvertJsonToObject <SalesInvoice>(json); var lines = (List <SalesInvoiceLine>)invoice.SalesInvoiceLines; Assert.IsNotNull(invoice); Assert.IsTrue(lines.Count > 0); }
public void EntityConverter_ConvertLinkedEntityJsonArrayToObjects_Succeeds() { string json = ApiResponseCleaner.GetJsonArray(JsonFileReader.GetJsonFromFile("Response_Json_Array_SalesInvoice_WithLinkedEntities.txt")); var converter = new EntityConverter(); List <SalesInvoice> invoices = converter.ConvertJsonArrayToObjectList <SalesInvoice>(json); foreach (var invoice in invoices) { var sil = (List <SalesInvoiceLine>)invoice.SalesInvoiceLines; Assert.IsTrue(sil.Count > 0); } }
public void EntityConverter_ConvertJsonToDynamicObjectCollection_Succeeds() { string json = JsonFileReader.GetJsonFromFile("Response_Json_Array_GLAccount.txt"); json = ApiResponseCleaner.GetJsonArray(json); List <dynamic> list = _entityConverter.ConvertJsonToDynamicObjectList(json); if (list.Count < 2) { throw new AssertFailedException("The list list doesn't contain two entities"); } }
public void EntityConverter_ConvertJsonToDynamicObject_WithCorrectJson_Succeeds() { string jsonsresponse = JsonFileReader.GetJsonFromFile("Response_Json_Object_GLAccount.txt"); string json = ApiResponseCleaner.GetJsonObject(jsonsresponse); dynamic glaccountObject = _entityConverter.ConvertJsonToDynamicObject(json); Assert.AreEqual("D", (string)glaccountObject.BalanceSide); Assert.AreEqual("W", (string)glaccountObject.BalanceType); Assert.AreEqual("4406", (string)glaccountObject.Code); Assert.AreEqual(false, (Boolean)glaccountObject.Compress); Assert.AreEqual(null, (string)glaccountObject.Costcenter); Assert.AreEqual(null, (string)glaccountObject.CostcenterDescription); Assert.AreEqual("10/25/2013 02:24:29", (string)glaccountObject.Created); Assert.AreEqual("99d87844-e4ef-4ac5-968c-fb863eaced16", (string)glaccountObject.Creator); Assert.AreEqual(null, (string)glaccountObject.CreatorFullName); Assert.AreEqual("Test", (string)glaccountObject.Description); Assert.AreEqual("499156", (string)glaccountObject.Division); Assert.AreEqual("0", (string)glaccountObject.ExcludeVATListing); Assert.AreEqual("0", (string)glaccountObject.ExpenseNonDeductiblePercentage); Assert.AreEqual("3c534e79-c4fe-44d2-9765-00b30573c2de", (string)glaccountObject.ID); Assert.AreEqual(false, (Boolean)glaccountObject.IsBlocked); Assert.AreEqual(false, (Boolean)glaccountObject.Matching); Assert.AreEqual("12/02/2013 13:44:27", (string)glaccountObject.Modified); Assert.AreEqual("10091f1b-4661-4854-9fd0-cf5f5f668cbd", (string)glaccountObject.Modifier); Assert.AreEqual("Edward Jackson", (string)glaccountObject.ModifierFullName); Assert.AreEqual(null, (string)glaccountObject.PrivateGLAccount); Assert.AreEqual("0", (string)glaccountObject.PrivatePercentage); Assert.AreEqual(null, (string)glaccountObject.ReportingCode); Assert.AreEqual(false, (Boolean)glaccountObject.RevalueCurrency); Assert.AreEqual("RENTE ", (string)glaccountObject.SearchCode); Assert.AreEqual("120", (string)glaccountObject.Type); Assert.AreEqual("Other costs", (string)glaccountObject.TypeDescription); Assert.AreEqual("0", (string)glaccountObject.UseCostcenter); Assert.AreEqual("0", (string)glaccountObject.UseCostunit); Assert.AreEqual(null, (string)glaccountObject.VATCode); Assert.AreEqual(null, (string)glaccountObject.VATDescription); Assert.AreEqual(null, (string)glaccountObject.VATGLAccountType); Assert.AreEqual(null, (string)glaccountObject.VATNonDeductibleGLAccount); Assert.AreEqual("0", (string)glaccountObject.VATNonDeductiblePercentage); Assert.AreEqual(null, (string)glaccountObject.YearEndCostGLAccount); Assert.AreEqual(null, (string)glaccountObject.YearEndReflectionGLAccount); }
public void EntityConverter_ConvertLongJson_Fails() { var entityConverter = new EntityConverter(); string json = JsonFileReader.GetJsonFromFile("Response_Json_Array_Account_Long.txt"); var accounts = entityConverter.ConvertJsonArrayToObjectList <Account>(json); }
public void ApiResponseCleaner_FetchJsonObject_WithoutDKeyValuePair_Fails() { ApiResponseCleaner.GetJsonObject(JsonFileReader.GetJsonFromFile("ApiResponse_Json_Object_WithoutD.txt")); }
public void ApiResponseCleaner_FetchJsonObject_WithCorrectValues_Succeeds() { ApiResponseCleaner.GetJsonObject(JsonFileReader.GetJsonFromFile("ApiResponse_Json_Object.txt")); }
public void ApiResponseCleaner_FetchJsonArray_WithOutResultsKeyValuePair_Fails() { ApiResponseCleaner.GetJsonArray(JsonFileReader.GetJsonFromFile("ApiResponse_Json_Array_WithoutResultsTag.txt")); }
public void ApiResponseCleaner_FetchJsonArray_WithCorrectValues_Succeeds() { string jsonarray = ApiResponseCleaner.GetJsonArray(JsonFileReader.GetJsonFromFile("ApiResponse_Json_Array.txt")); }