public void Can_Serialize_From_Json_Model() { var converter = new ArchetypeValueConverter(); var result = (Archetype.Umbraco.Models.Archetype)converter.ConvertDataToSource(null, _sampleJson, false); Assert.That(result != null); Assert.That(result.Fieldsets.Count() == 2); }
public void Can_Get_Fieldset_Property_By_Alias() { var converter = new ArchetypeValueConverter(); var result = (Archetype.Umbraco.Models.Archetype)converter.ConvertDataToSource(null, _sampleJson, false); var fieldset = result.Fieldsets.First(); var propertyValue = fieldset.GetValue("boxHeadline"); Assert.That(propertyValue == "Box 1 Title"); }
public void Returns_Empty_Archetype_When_Data_Is_Null_Or_Empty(object data) { var converter = new ArchetypeValueConverter(); var result = converter.ConvertDataToSource(null, data, false); Assert.AreEqual(result.GetType(), typeof (Archetype.Umbraco.Models.Archetype)); var fieldsets = (Archetype.Umbraco.Models.Archetype) result; Assert.IsTrue(fieldsets.Count() == 0); }
public void Returns_String_When_No_Type_Specified() { var converter = new ArchetypeValueConverter(); var result = (Archetype.Umbraco.Models.Archetype)converter.ConvertDataToSource(null, _sampleJson, false); var fieldset = result.Fieldsets.First(); var property = fieldset.GetValue("link"); Assert.That(property is string); Assert.That(property == "3175"); }
public void Can_Convert_Property_Value_Types() { var converter = new ArchetypeValueConverter(); var result = (Archetype.Umbraco.Models.Archetype)converter.ConvertDataToSource(null, _sampleJson, false); var fieldset = result.Fieldsets.First(); Assert.That(fieldset.GetValue<int>("link") == 3175); Assert.That(fieldset.GetValue<bool>("show") == true); Assert.That(fieldset.GetValue<string>("blurb") == "A blurb here"); }