public void ShouldOverrideBindingRules() { _binder.Bind(x => x.Int.ToString()).To(x => x.String); _binder.Bind(x => x.String2).To(x => x.String); _stub = new UniversalStub(); using (_binder.Attach(_stub)) { _stub.String.ShouldBe(null); using (_stub.VerifyNotChanged("String")) { _stub.Int = 1; } _stub.String2.ShouldBe(null); using (_stub.VerifyChangedOnce("String")) { _stub.String2 = "a"; } _stub.String2.ShouldBe("a"); } }
public void ShouldOverrideBindingRules() { _binder.Bind(x => x.Int.ToString()).To(x => x.String); _binder.Bind(x => x.String2).To(x => x.String); _stub = new UniversalStub(); using (_binder.Attach(_stub)) { _stub.String.ShouldBe(null); using (_stub.VerifyNotChanged("String")) { _stub.Int = 1; } _stub.String2.ShouldBe(null); using (_stub.VerifyChangedOnce("String")) { _stub.String2 = "a"; } _stub.String2.ShouldBe("a"); } }
public void ShouldOverrideConditionalBindingRulesByCustomKey() { _binder.BindIf(x => true, x => x.Int.ToString()).OverrideKey("mykey").To((x, v) => x.String = v); _binder.BindIf(x => true, x => x.String2).OverrideKey("mykey").To((x, v) => x.String = v); _stub = new UniversalStub(); using (_binder.Attach(_stub)) { _stub.String.ShouldBe(null); using (_stub.VerifyNotChanged("String")) { _stub.Int = 1; } _stub.String2.ShouldBe(null); using (_stub.VerifyChangedOnce("String")) { _stub.String2 = "a"; } _stub.String2.ShouldBe("a"); } }
public void ShouldOverrideConditionalBindingRulesByCustomKey() { _binder.BindIf(x => true, x => x.Int.ToString()).OverrideKey("mykey").To((x, v) => x.String = v); _binder.BindIf(x => true, x => x.String2).OverrideKey("mykey").To((x, v) => x.String = v); _stub = new UniversalStub(); using (_binder.Attach(_stub)) { _stub.String.ShouldBe(null); using (_stub.VerifyNotChanged("String")) { _stub.Int = 1; } _stub.String2.ShouldBe(null); using (_stub.VerifyChangedOnce("String")) { _stub.String2 = "a"; } _stub.String2.ShouldBe("a"); } }