public void BooleanConverter() { var model = new FakeModel() { BoolProperty = true, NullableBool = true }; var type = model.GetType(); var property1 = model.GetType().GetProperty("BoolProperty"); var property2 = model.GetType().GetProperty("NullableBool"); var converter = new BooleanConverter(); Assert.IsTrue(converter.Match(property1)); Assert.IsTrue(converter.Match(property2)); var info1 = converter.GetValue(model, property1); Assert.AreEqual("1", info1); var info2 = converter.GetValue(model, property2); Assert.AreEqual("1", info2); model.NullableBool = null; var info3 = converter.GetValue(model, property2); Assert.AreEqual("null", info3); }
public void GetValue_WhenCalled_IsValid() { BooleanConverter converter = new BooleanConverter("T", "F"); var trueResult = converter.GetValue("T"); var falseResult = converter.GetValue("F"); Assert.True(trueResult); Assert.False(falseResult); }
public void GetValue_InalidValue_ThrowsApplicationException() { BooleanConverter converter = new BooleanConverter("T", "F"); Action action = () => converter.GetValue("True"); Assert.Throws <ApplicationException>(action); }
public void GetValue_InalidValue_ThrowsApplicationException() { BooleanConverter converter = new BooleanConverter("T", "F"); Action action = ()=> converter.GetValue("True"); Assert.Throws<ApplicationException>(action); }