public static void CustomizeContentMediaSubtype(this IFixture fixture) { fixture.Customize <ContentMediaSubtype>(customization => customization.FromFactory <int>(value => ContentMediaSubtype.Parse(CreateContentMediaSubtypeString(value)) )); }
public static ContentType Parse(string value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var parts = value.Split('/'); if (parts.Length != 2) { throw new FormatException("The content type value is not a well formed 'type/subtype'."); } var type = ContentMediaType.Parse(parts[0]); var subtype = ContentMediaSubtype.Parse(parts[1]); return(new ContentType(type, subtype)); }
public static bool TryParse(string value, out ContentType parsed) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var parts = value.Split('/'); if (parts.Length == 2 && ContentMediaType.TryParse(parts[0], out var type) && ContentMediaSubtype.TryParse(parts[1], out var subtype)) { parsed = new ContentType(type, subtype); return(true); } parsed = default; return(false); }
private ContentType(ContentMediaType type, ContentMediaSubtype subtype) { _type = type; _subtype = subtype; }
public void ParseValueCanNotBeNull() { Assert.Throws <ArgumentNullException>(() => ContentMediaSubtype.Parse(null)); }