public void TryGet_NonExistant_ReturnsFalse() { var name = "wolfbear"; IManosTemplate template = null; Assert.IsFalse(TemplateFactory.TryGet(name, out template)); }
public static bool TryGet(string name, out IManosTemplate template) { if (name == null) throw new ArgumentNullException ("name"); return templates.TryGetValue (name, out template); }
public static bool TryGet(string name, out IManosTemplate template) { if (name == null) { throw new ArgumentNullException("name"); } return(templates.TryGetValue(name, out template)); }
public static IManosTemplate Get(string name) { IManosTemplate res = null; if (!TryGet(name, out res)) { return(null); } return(res); }
public static void Register(string name, IManosTemplate template) { if (name == null) throw new ArgumentNullException ("name"); if (template == null) throw new ArgumentNullException ("template"); if (templates.ContainsKey (name)) throw new InvalidOperationException (String.Format ("A template named {0} has already been registered.", name)); templates.Add (name, template); }
public void TryGet_RegisteredTemplate_SetsTemplate() { var name = "manbearpig"; IManosTemplate expected = new ManosTemplateStub(); TemplateFactory.Register(name, expected); IManosTemplate actual = null; TemplateFactory.TryGet(name, out actual); Assert.AreSame(expected, actual); }
public static void Register(string name, IManosTemplate template) { if (name == null) { throw new ArgumentNullException("name"); } if (template == null) { throw new ArgumentNullException("template"); } if (templates.ContainsKey(name)) { throw new InvalidOperationException(String.Format("A template named {0} has already been registered.", name)); } templates.Add(name, template); }