public void NextAvailable() { var binder = new ObjectBinderBuilder <object>(); binder.Use(typeof(Binder)); var called = false; binder.Use(n => c => { called = true; }); var ctx = new BindingContext <object>(ObjectBindingDirection.In, null); binder.Build()(ctx); Assert.True(called); }
public void WrongBindMethodThrows() { var binder = new ObjectBinderBuilder <object>(); binder.Use(typeof(WrongBindMethodGenericParameter)); Assert.Throws <InvalidOperationException>(() => binder.Build()); }
public void MissingBindMethodThrows() { var binder = new ObjectBinderBuilder <object>(); binder.Use(typeof(MissingBindMethod)); Assert.Throws <InvalidOperationException>(() => binder.Build()); }
public void ConstructorArgsPassed() { var binder = new ObjectBinderBuilder <object>(); binder.Use(typeof(BinderWithCtrArgs), "str"); var ctx = new BindingContext <object>(ObjectBindingDirection.In, null); binder.Build()(ctx); Assert.Equal("str", ctx.ObjectValue as string); }
public void BindCalled() { var binder = new ObjectBinderBuilder <object>(); binder.Use(typeof(Binder)); var ctx = new BindingContext <object>(ObjectBindingDirection.In, null); binder.Build()(ctx); Assert.Equal("string", ctx.ObjectValue as string); }
public void ComponentsCalledInOrder() { var stringBuilder = new StringBuilder(); var builder = new ObjectBinderBuilder <object>(); builder.Use(next => ctx => { stringBuilder.Append("1"); next(ctx); }); builder.Use(next => ctx => { stringBuilder.Append("2"); next(ctx); }); var binder = builder.Build(); binder(new BindingContext <object>(ObjectBindingDirection.In, null)); Assert.Equal("12", stringBuilder.ToString()); }