为什么XUnit attributs无法识别?

时间:2013-07-04 02:58:57

标签: vb.net xunit xunit.net

我用NuGet安装了库xUnit,并添加了引用,但由于属性[Theory],[InlineData(“11/12/2011”,“2011-11-12”)]和[Fact],我有错误

Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports System.Text.RegularExpressions
Imports FluentAssertions
Imports Xunit
Imports System
Imports System.Diagnostics
Imports Xunit.Extensions

Public Class XUnitClassTest



[Theory]
[InlineData("11/12/2011","2011-11-12")]
Public Sub test(input As String, output As String)

    Dim pattern As String = "\d+|[A-Za-zÀàÂâÄäÇçÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÜü']+"
    Dim matchList As MatchCollection = Regex.Matches(input, pattern)
    Dim matchArray(matchList.Count - 1) As Match
    matchList.CopyTo(matchArray, 0)

    Dim manager As Processeur = New Processeur

    manager.GetData(matchArray.Select(Function(a) a.ToString())).Should().Be(output)

End Sub

[Fact]
Public Sub FactMethodName()

    Write(DateTime.Parse("1658").ToString())

End Sub


Public Shared Sub Write(format As String, ParamArray param As Object())

    Console.WriteLine(format, param)

End Sub

结束班

1 个答案:

答案 0 :(得分:4)

您在VB.NET中使用C#属性语法 VB.NET语法将是

<Fact>
Public Sub FactMethodName()
    Write(DateTime.Parse("1658").ToString())
End Sub

等等。