public void Test_AssertPropBoundToTextBox_WithLambda_WhenIsNot_ShouldReturnFalse() { //---------------Set up test pack------------------- var textBox = GenerateStub <TextBox>(); var textBoxName = GetRandomString(); textBox.Name = textBoxName; var controlBinder = new HabaneroControlBinder <FakeBoWithOnProp>(); const string propName = "FakeBOName"; var otherTextBox = GenerateStub <TextBox>(); var textBoxMapper = controlBinder.Add <TextBoxMapper, TextBox>(otherTextBox, propName); var bindingTester = new BindingTester <FakeBoWithOnProp>(controlBinder); //---------------Assert Precondition---------------- controlBinder.ControlMappers.Contains(textBoxMapper); Assert.AreNotSame(textBox, textBoxMapper.Control); //---------------Execute Test ---------------------- try { bindingTester.AssertPropBoundTo(textBox, bo => bo.FakeBOName); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expectedMsg = string.Format("The Property '{0}' for class '{1}' should be mapped to '{2}'", propName, "FakeBoWithOnProp", textBoxName); StringAssert.Contains(expectedMsg, ex.Message); } }
public void Test_ConstructBindingTester_ShouldConstruct() { //---------------Set up test pack------------------- var controlBinder = new HabaneroControlBinder <FakeBoWithOnProp>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bindingTester = new BindingTester <FakeBoWithOnProp>(controlBinder); //---------------Test Result ----------------------- Assert.IsNotNull(bindingTester); }
public void Bind() { var value = new BindingTester(); Binder.Bind(ref value, injector); Assert.AreEqual("public-field", value.BoundPublicField); Assert.AreEqual("protected-field", value.BoundProtectedField); Assert.AreEqual("private-field", value.BoundPrivateField); Assert.AreEqual("public-property", value.BoundPublicProperty); Assert.AreEqual("protected-property", value.BoundProtectedProperty); Assert.AreEqual("private-property", value.BoundPrivateProperty); Assert.IsNull(value.PublicField); }
public void Test_AssertPropBound_WhenIs_ShouldReturnTrue() { //---------------Set up test pack------------------- var textBox = new TextBox(); var controlBinder = new HabaneroControlBinder <FakeBoWithOnProp>(); const string propName = "FakeBOName"; controlBinder.Add <TextBoxMapper, TextBox>(textBox, propName); var bindingTester = new BindingTester <FakeBoWithOnProp>(controlBinder); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- bindingTester.AssertPropBoundTo(textBox, propName); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed."); }
public void Test_AssertPropBound_WhenIsNotBoundToAnything_ShouldReturnFalse() { //---------------Set up test pack------------------- var controlBinder = new HabaneroControlBinder <FakeBoWithOnProp>(); const string propName = "FakeBOName"; var bindingTester = new BindingTester <FakeBoWithOnProp>(controlBinder); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { bindingTester.AssertPropBoundTo(GenerateStub <CheckBox>(), propName); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expectedMsg = string.Format("The Property '{0}' for class '{1}' should be mapped", propName, "FakeBoWithOnProp"); StringAssert.Contains(expectedMsg, ex.Message); } }