相关疑难解决方法(0)

如何在C#中单元测试Textrenderer.DrawText方法

public static void DrawText(IDeviceContext dc, string text, Font font, Point pt, Color foreColor, TextFormatFlags flags);
Run Code Online (Sandbox Code Playgroud)

我有一个测试器应用程序,用于我的ExtendedComboBox.以下代码中给出的所有String项目都存在于我的测试器应用程序中的ComboBox项目中.如何对上述方法进行单元测试,因为它返回void?测试TextRenderer.Drawtext的另一种方法是什么?是否有任何替代测试OnDrawItem方法来绘制ComboBox文本.

[TestMethod()]
public void ExtendedComboBoxOnDrawPrefixTest()
{
    ExtendedComboBox cboTest = new ExtendedComboBox ();

    // List of strings having special characters.

    string[] items = { 
        "&One",
        "T&wo",
        "E!xclamation",
        "Am@persat",
        "H#ash",
        "Dollar$Sign",
        "Perc%ent",
        "Ci^rcumflex",
        "Ast*erisk",
        "Hy-phen",
        "Und_erscore",
        "pl+us",
        "Equ=als",
        "Col:on",
        "Semi;colon",
        "Co'mma",
        "Inverted\"Comma",
        "Apos'trophe",
        "Pip|e",
        "Open{Brace",
        "Close}Brace",
        "OpenBr[acket",
        "CloseBr]acket",
        "BackS\\lash",
        "ForwardSl/ash",
        "LessT<han",
        "Greate>rThan",
        "Questio?nMark",
        "Do.t",
        "Three",
        "Four",
        "Five",
        "Six",
        "This is a really extremely long string value for …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing

2
推荐指数
1
解决办法
422
查看次数

标签 统计

c# ×1

unit-testing ×1