public void BooleanTypeConverterTests() { PrimitiveTypeConverter converter = new BooleanTypeConverter(); Assert.AreEqual(true, converter.Parse("true")); Assert.AreEqual(false, converter.Parse("false")); Assert.AreEqual("true", converter.ToString(true)); Assert.AreEqual("false", converter.ToString(false)); }
public void Should_AppendBooleanTypeConverter_When_BooleanFieldIsAppended() { var layout = new LayoutDescriptor <PrimitiveTypesModel>() .AppendField(x => x.boolTest, fieldLength); var field = layout.GetOrderedFields().FirstOrDefault(); var expectedType = new BooleanTypeConverter(); Assert.IsInstanceOfType(field.TypeConverter, expectedType.GetType()); }
public void TokenizeFromXmlTestHandlesReaderPositionAndReturnsCorrectTokens() { XElement xel = XElement.Parse("<element>true</element>"); var r = xel.CreateReader(); r.Read(); PrimitiveTypeConverter converter = new BooleanTypeConverter(); var token = converter.TokenizeFromXml(r); Assert.AreEqual(typeof(TextPrimitiveParserToken), token.GetType()); Assert.AreEqual(XmlNodeType.EndElement, r.NodeType); Assert.AreEqual("element", r.LocalName); Assert.AreEqual(true, token.Materialize(typeof(Boolean))); }
public void BooleanTypeConverterTest() { var converter = new BooleanTypeConverter(); Assert.True(converter.CanConvertFrom(typeof(string))); Assert.True(converter.CanConvertTo(typeof(string))); Assert.Equal(true, converter.ConvertFrom("true")); Assert.Equal(true, converter.ConvertFrom("True")); Assert.Equal(true, converter.ConvertFrom("1")); Assert.Equal(false, converter.ConvertFrom("false")); Assert.Equal(false, converter.ConvertFrom("False")); Assert.Equal(false, converter.ConvertFrom("0")); }