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