public void CanCastStringAttribute() { object attributeValue = "tester"; var output = CredentialUtils.CastAttribute(attributeValue, CredentialMimeTypes.TextMimeType); Assert.IsType <string>(output); }
public override CredentialPreviewAttribute ReadJson(JsonReader reader, Type objectType, CredentialPreviewAttribute existingValue, bool hasExistingValue, JsonSerializer serializer) { var item = JObject.Load(reader); var name = item["name"]; var value = item["value"]; var mimeType = item["mime-type"]; var obj = new CredentialPreviewAttribute(); obj.Name = name.Value <string>(); obj.MimeType = mimeType.HasValues ? mimeType.Value <string>() : CredentialMimeTypes.TextMimeType; obj.Value = CredentialUtils.CastAttribute(value, obj.MimeType); return(obj); }