本文整理汇总了C#中DateTimeFormatInfo.GetFormat方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.GetFormat方法的具体用法?C# DateTimeFormatInfo.GetFormat怎么用?C# DateTimeFormatInfo.GetFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.GetFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: Call GetFormat to to get an valid DateTimeFormatInfo instance");
try
{
DateTimeFormatInfo expected = new DateTimeFormatInfo();
object obj = expected.GetFormat(typeof(DateTimeFormatInfo));
if (!(obj is DateTimeFormatInfo))
{
TestLibrary.TestFramework.LogError("001.1", "Calling GetFormat returns a non DateTimeFormatInfo instance");
retVal = false;
}
DateTimeFormatInfo actual = obj as DateTimeFormatInfo;
if (actual != expected)
{
TestLibrary.TestFramework.LogError("001.2", "Calling GetFormat returns wrong instance");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例2: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: If the format type is not supported, null reference should be return");
try
{
DateTimeFormatInfo info = new DateTimeFormatInfo();
if (info.GetFormat(typeof(Object)) != null)
{
TestLibrary.TestFramework.LogError("002.1", "If the format type is not supported, null reference is not returned");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例3: GetFormat_UnsupportedFormatType_ReturnsNull
public void GetFormat_UnsupportedFormatType_ReturnsNull()
{
DateTimeFormatInfo info = new DateTimeFormatInfo();
Assert.Null(info.GetFormat(typeof(object)));
}
示例4: GetFormat
public void GetFormat()
{
DateTimeFormatInfo expected = new DateTimeFormatInfo();
DateTimeFormatInfo format = (DateTimeFormatInfo)expected.GetFormat(typeof(DateTimeFormatInfo));
Assert.Same(expected, format);
}