public void CanUnBind() { var container = new CatLib.Stl.Container(); var bindData = container.Bind("CanUnBind", (app, param) => "hello world", false); Assert.AreEqual("hello world", container.Make("CanUnBind").ToString()); bindData.UnBind(); Assert.AreEqual(null, container.Make("CanUnBind")); }
public void CheckIllegalResolving() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "CanAddOnResolving", (app, param) => "hello world", false); ExceptionAssert.Throws <ArgumentNullException>(() => { bindData.OnResolving(null); }); }
public void CheckNeedsIsNotNull() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "NeedsIsNotNull", (app, param) => "hello world", false); var needs = bindData.Needs("TestService"); var needsWithType = bindData.Needs <BindDataTest>(); Assert.AreNotEqual(null, needs); Assert.AreNotEqual(null, needsWithType); }
public void AddContextualRepeat() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "AddContextualRepeat", (app, param) => "hello world", false); bindData.AddContextual("service", "service given"); ExceptionAssert.Throws <RuntimeException>(() => { bindData.AddContextual("service", "service given"); }); }
public void CanAddOnResolving() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "CanAddOnResolving", (app, param) => "hello world", false); bindData.OnResolving((bind, obj) => null); var data = bindData.ExecResolvingDecorator(new CatLib.Stl.Container()); Assert.AreEqual(null, data); }
public void CanGetContextual() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "NeedsIsNotNull", (app, param) => "hello world", false); bindData.Needs("need1").Given("abc"); bindData.Needs("need2").Given <BindDataTest>(); Assert.AreEqual("abc", bindData.GetContextual("need1")); Assert.AreEqual(typeof(BindDataTest).ToString(), bindData.GetContextual("need2")); Assert.AreEqual("empty", bindData.GetContextual("empty")); }
public void CheckIllegalUnBindInput() { var container = new CatLib.Stl.Container(); var bindData = container.Bind("CanUnBind", (app, param) => "hello world", false); bindData.UnBind(); ExceptionAssert.Throws <RuntimeException>(() => { bindData.Alias("hello"); }); }
public void CanOnRelease() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "CanAddOnRelease", (app, param) => "hello world", true); bindData.OnRelease((bind, obj) => { Assert.AreEqual("Test", obj); Assert.AreSame(bindData, bind); }); container.Instance("CanAddOnRelease", "Test"); container.Release("CanAddOnRelease"); }
public void CheckIllegalAlias() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "CheckIllegalAlias", (app, param) => "hello world", false); ExceptionAssert.Throws <ArgumentNullException>(() => { bindData.Alias(null); }); ExceptionAssert.Throws <ArgumentNullException>(() => { bindData.Alias(string.Empty); }); }
public void CanAddAlias() { var container = new CatLib.Stl.Container(); var bindData = container.Bind("CanAddAlias", (app, param) => "hello world", false); bindData.Alias("Alias"); bindData.Alias <BindDataTest>(); var textAliasGet = container.GetBind("Alias"); Assert.AreSame(textAliasGet, bindData); var classAliasGet = container.GetBind(typeof(BindDataTest).ToString()); Assert.AreSame(bindData, textAliasGet); Assert.AreSame(bindData, classAliasGet); }
public void CheckIllegalRelease() { var container = new CatLib.Stl.Container(); var bindData = new CatLib.Stl.BindData(container, "CheckIllegalRelease", (app, param) => "hello world", false); ExceptionAssert.Throws <ArgumentNullException>(() => { bindData.OnRelease(null); }); ExceptionAssert.Throws <RuntimeException>(() => { bindData.OnRelease((bind, obj) => { Assert.Fail(); }); container.Instance("CheckIllegalRelease", "Test"); container.Release("CheckIllegalRelease"); }); }