English 中文(简体)
测试 执行
原标题:TestCleanup() Implementation

How would I write the [TestCleanup()] method for these [TestMethod()] s.

我有以下11点:

当他们单独经营时,如果不能同时办理第一次通行证

[TestMethod()]
public void SplitTdsNameTest_SimpleValidName2()
{
    string tdsName = "Mr Daniel George Trunley";
    MemberName expected = new MemberName("Mr", "Daniel George", "Trunley");
    MemberName actual;
    actual = TdsTransformer.SplitTdsName(tdsName);
    Assert.AreEqual(expected, actual);
}


[TestMethod()]
public void SplitTdsNameTest_SimpleValidName3()
{
    string tdsName = "Daniel George Trunley";
    MemberName expected = new MemberName("", "", "Daniel George Trunley");
    MemberName actual;
    actual = TdsTransformer.SplitTdsName(tdsName);
    Assert.AreEqual(expected, actual);
}

MemberName:

public struct MemberName
{
    public string Title;
    public string FirstNames;
    public string LastNames;

    public MemberName(string title, string firstNames, string lastNames)            
    {            
        Title = title;
        FirstNames = firstNames;
        LastNames = lastNames;
    }
}

辅助器:

public MemberName SplitTdsName(string tdsName)
    {
        return NameSplitter.Splitter(tdsName);
    }

排放者:

public static MemberName Splitter(string fullName)
    {
        nameInFull = fullName;
        SetAllowedTitles();
        SplitNamesAndRemovePeriods();
        SetTitles();
        MemberName splitName = new MemberName(titles, firstNames, lastNames);
        return splitName;
    }
最佳回答

Based on what s provided, it doesn t look like any cleanup is necessary.

如果有<条码> 试验/代码>方法,则仅公布其所做工作。

如果Tds Transformer. SplitTdsName 储存任何内部状态,你也必须明确这一点。 虽然它does,但它可能是固定方法。

根据its,这两种方法令我感到担忧:

    SetAllowedTitles();
    SetTitles();

这意味着存在内部状态,我认为,静态等级为极坏>。 这很可能是你通过连续测试发现的问题。

更正 保持静态,使其回归价值而不是在静态成员中储存:

    var allowedTitles = SetAllowedTitles(fullName);
    var names = SplitNamesAndRemovePeriods(fullName);  //likely a struct or class with first/last names
    var titles = SetTitles(allowedTitles);
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签