示例#1
0
    public void DeserializeShortCategoriesWithNullCollectionPasses()
    {
        List <CmpShortCategoryModel> shortCategories = null;

        NativeUiJsonDeserializer.DeserializeShortCategories(ONE_SHORT_CATEGORY_COLLECTION_JSON, ref shortCategories);
        Assert.NotNull(shortCategories);
    }
示例#2
0
    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);
    }
示例#3
0
    public void DeserializeShortCategoriesFailsWithInvalidOperationException()
    {
        List <CmpShortCategoryModel> shortCategories = null;

        Assert.Throws <InvalidOperationException>(
            delegate
        {
            NativeUiJsonDeserializer.DeserializeShortCategories(ONE_ODD_SHORT_CATEGORY_COLLECTION_JSON_3, ref shortCategories);
        });
    }
示例#4
0
    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);
    }
示例#5
0
    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);
    }