System Object DeltaEngine.Extensions StringExtensionsNamespace: DeltaEngine.ExtensionsAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
public static class StringExtensions
public static class StringExtensions
<ExtensionAttribute>
Public NotInheritable Class StringExtensions
<ExtensionAttribute>
Public NotInheritable Class StringExtensions
[ExtensionAttribute]
public ref class StringExtensions abstract sealed
[ExtensionAttribute]
public ref class StringExtensions abstract sealed
[<AbstractClassAttribute>]
[<SealedAttribute>]
type StringExtensions = class end
[<AbstractClassAttribute>]
[<SealedAttribute>]
type StringExtensions = class end
The StringExtensions type exposes the following members.
TopTests:
DeltaEngine.Tests.Extensions.StringExtensionsTests21 unit tests call DeltaEngine.Extensions.StringExtensions
[Test]
public void ConvertFloatToInvariantString()
{
Assert.AreEqual("2.5", 2.5f.ToInvariantString());
Assert.AreNotEqual("3.5", 1.5f.ToInvariantString());
Assert.AreEqual("01", 1.0f.ToInvariantString("00"));
Assert.AreEqual("1.23", 1.2345f.ToInvariantString("0.00"));
Assert.AreNotEqual("1.2345", 1.2345f.ToInvariantString("0.00"));
Assert.AreEqual("1", StringExtensions.ToInvariantString(1));
}
[Test]
public void ConvertFloatToInvariantString()
{
Assert.AreEqual("2.5", 2.5f.ToInvariantString());
Assert.AreNotEqual("3.5", 1.5f.ToInvariantString());
Assert.AreEqual("01", 1.0f.ToInvariantString("00"));
Assert.AreEqual("1.23", 1.2345f.ToInvariantString("0.00"));
Assert.AreNotEqual("1.2345", 1.2345f.ToInvariantString("0.00"));
Assert.AreEqual("1", StringExtensions.ToInvariantString(1));
}
[Test]
public void Convert()
{
Assert.AreEqual(1.0f, "1.0".Convert<float>());
Assert.AreEqual("abc", "abc".Convert<string>());
Assert.Throws<FormatException>(() => "val".Convert<float>());
Assert.AreEqual(1, "1".Convert<int>());
Assert.AreEqual(24, "24".Convert<int>());
Assert.AreEqual('A', "A".Convert<char>());
Assert.AreEqual(943578.39543, "943578.39543".Convert<double>());
Assert.AreEqual(true, "True".Convert<bool>());
Assert.AreEqual(false, "False".Convert<bool>());
Assert.AreEqual(SomeEnum.Additive, "Additive".Convert<SomeEnum>());
Assert.AreEqual(new DateTime(2002, 12, 24), "2002-12-24".Convert<DateTime>());
}
[Test]
public void Convert()
{
Assert.AreEqual(1.0f, "1.0".Convert<float>());
Assert.AreEqual("abc", "abc".Convert<string>());
Assert.Throws<FormatException>(() => "val".Convert<float>());
Assert.AreEqual(1, "1".Convert<int>());
Assert.AreEqual(24, "24".Convert<int>());
Assert.AreEqual('A', "A".Convert<char>());
Assert.AreEqual(943578.39543, "943578.39543".Convert<double>());
Assert.AreEqual(true, "True".Convert<bool>());
Assert.AreEqual(false, "False".Convert<bool>());
Assert.AreEqual(SomeEnum.Additive, "Additive".Convert<SomeEnum>());
Assert.AreEqual(new DateTime(2002, 12, 24), "2002-12-24".Convert<DateTime>());
}
[Test]
public void ToInvariantString()
{
Assert.AreEqual("null", StringExtensions.ToInvariantString(null));
Assert.AreEqual("1", StringExtensions.ToInvariantString((object)1.0f));
Assert.AreEqual("1.2", StringExtensions.ToInvariantString(1.2));
Assert.AreEqual("1.4", StringExtensions.ToInvariantString(1.4m));
Assert.AreEqual("abc", StringExtensions.ToInvariantString("abc"));
Assert.AreEqual("01/01/2014 00:00:00",
StringExtensions.ToInvariantString(new DateTime(2014, 1, 1)));
}
[Test]
public void ToInvariantString()
{
Assert.AreEqual("null", StringExtensions.ToInvariantString(null));
Assert.AreEqual("1", StringExtensions.ToInvariantString((object)1.0f));
Assert.AreEqual("1.2", StringExtensions.ToInvariantString(1.2));
Assert.AreEqual("1.4", StringExtensions.ToInvariantString(1.4m));
Assert.AreEqual("abc", StringExtensions.ToInvariantString("abc"));
Assert.AreEqual("01/01/2014 00:00:00",
StringExtensions.ToInvariantString(new DateTime(2014, 1, 1)));
}