本文整理汇总了C#中UnicodeEncoding.GetMaxCharCount方法的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding.GetMaxCharCount方法的具体用法?C# UnicodeEncoding.GetMaxCharCount怎么用?C# UnicodeEncoding.GetMaxCharCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeEncoding
的用法示例。
在下文中一共展示了UnicodeEncoding.GetMaxCharCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public bool PosTest1()
{
bool retVal = true;
int expectedValue = 1;
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method and set byteCount as 0.");
try
{
actualValue = uE.GetMaxCharCount(0);
if (expectedValue != actualValue)
{
TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
retVal = false;
}
return retVal;
}
示例2: PosTest2
public void PosTest2()
{
int expectedValue = 2;
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
actualValue = uE.GetMaxCharCount(1);
Assert.Equal(expectedValue, actualValue);
}
示例3: NegTest1
public void NegTest1()
{
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
actualValue = uE.GetMaxCharCount(-1);
});
}
示例4: PosTest3
public void PosTest3()
{
int byteCount = _generator.GetInt32(-55);
int expectedValue = (byteCount + 1) / 2 + 1;
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
actualValue = uE.GetMaxCharCount(byteCount);
Assert.Equal(expectedValue, actualValue);
}
示例5: NegTest1
public bool NegTest1()
{
bool retVal = true;
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
TestLibrary.TestFramework.BeginScenario("NegTest1:Invoke the method and set byteCount as -1.");
try
{
actualValue = uE.GetMaxCharCount(-1);
TestLibrary.TestFramework.LogError("007", "No ArgumentOutOfRangeException expected.");
retVal = false;
}
catch (ArgumentOutOfRangeException)
{
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("008", "Unexpected exception:" + e);
retVal = false;
}
return retVal;
}
示例6: PosTest3
public bool PosTest3()
{
bool retVal = true;
int byteCount = TestLibrary.Generator.GetInt32(-55);
int expectedValue = (byteCount + 1) / 2 + 1;
int actualValue;
UnicodeEncoding uE = new UnicodeEncoding();
TestLibrary.TestFramework.BeginScenario("PosTest3:Invoke the method and set byteCount as random integer.");
try
{
actualValue = uE.GetMaxCharCount(byteCount);
if (expectedValue != actualValue)
{
TestLibrary.TestFramework.LogError("005", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("006", "Unexpected exception:" + e);
retVal = false;
}
return retVal;
}