public void DeserializeShortCategoriesWithNullCollectionPasses() { List <CmpShortCategoryModel> shortCategories = null; NativeUiJsonDeserializer.DeserializeShortCategories(ONE_SHORT_CATEGORY_COLLECTION_JSON, ref shortCategories); Assert.NotNull(shortCategories); }
public void DeserializeShortCategoriesPassesWithEmptyCollection() { List <CmpShortCategoryModel> shortCategories = null; NativeUiJsonDeserializer.DeserializeShortCategories(ONE_ODD_SHORT_CATEGORY_COLLECTION_JSON_2, ref shortCategories); Assert.NotNull(shortCategories); Assert.AreEqual(shortCategories.Count, 0); }
public void DeserializeShortCategoriesFailsWithInvalidOperationException() { List <CmpShortCategoryModel> shortCategories = null; Assert.Throws <InvalidOperationException>( delegate { NativeUiJsonDeserializer.DeserializeShortCategories(ONE_ODD_SHORT_CATEGORY_COLLECTION_JSON_3, ref shortCategories); }); }
public void DeserializeShortCategoriesPassesWithNullElements() { List <CmpShortCategoryModel> shortCategories = null; NativeUiJsonDeserializer.DeserializeShortCategories(ONE_ODD_SHORT_CATEGORY_COLLECTION_JSON, ref shortCategories); Assert.NotNull(shortCategories); Assert.AreEqual(shortCategories.Count, 1); Assert.IsNull(shortCategories[0]._id); Assert.IsNull(shortCategories[0].type); Assert.IsNull(shortCategories[0].name); Assert.IsNull(shortCategories[0].description); }
public void DeserializeShortCategoriesWithNotNullCollectionPasses() { List <CmpShortCategoryModel> shortCategories = new List <CmpShortCategoryModel> { new CmpShortCategoryModel() }; NativeUiJsonDeserializer.DeserializeShortCategories(ONE_SHORT_CATEGORY_COLLECTION_JSON, ref shortCategories); Assert.NotNull(shortCategories); Assert.AreEqual(shortCategories.Count, 2); var sublist = shortCategories.GetRange(1, 1); var sublistJson = JsonSerializer.Serialize(sublist); var deserialized = JsonSerializer.Deserialize <List <CmpShortCategoryModel> >(sublistJson); Assert.AreEqual(deserialized[0]._id, sublist[0]._id); Assert.AreEqual(deserialized[0].name, sublist[0].name); Assert.AreEqual(deserialized[0].type, sublist[0].type); Assert.AreEqual(deserialized[0].description, sublist[0].description); }