public void GuardResponse() { if (_response == null) { throw TagException.HttpResponseNotAvailable(); } }
private void AddTag(string name, ITagFactory factory) { if (REGISTERED_TAGS.ContainsKey(name)) { throw TagException.DuplicateTag(name, REGISTERED_TAGS.Keys.ToArray()); } REGISTERED_TAGS.Add(factory.Name, factory); }
public static void Check(ITag tag) { IDictionary <PropertyInfo, RequiredAttribute> requiredProperties = GetRequiredProperties(tag); List <string> missingProperties = CollectMissingProperties(requiredProperties, tag); if (missingProperties.Count > 0) { throw TagException.MissingRequiredAttribute(tag.GetType(), missingProperties.ToArray()).Decorate( tag.Context); } }
public ITag Get(string name, ParseContext context) { if (REGISTERED_TAGS.ContainsKey(name)) { ITag tag = REGISTERED_TAGS[name].NewInstance(); tag.Context = context; tag.Group = this; return(tag); } throw TagException.UnkownTag(name, TagNames).Decorate(context); }
public ITagGroup Get(string group, ParseContext context = null) { if (_tags.ContainsKey(group)) { return(_tags[group]); } if (context != null) { throw TagException.UnkownTagGroup(group).Decorate(context); } return(null);; }
private void Validate(Func<TestTag, ITagAttribute> action, TagException expectedException) { // Given var tag = CreateTag(action); var validator = new NumberTagAttributeValidator(); // When TagException result = null; try { validator.Validate(tag); } catch (TagException e) { result = e; } Assert.That(result?.Message, Is.EqualTo(expectedException?.Message), tag.NumberValue?.ToString()); }