1

我使用 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

结束类

4

1 回答 1

4

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

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

等等。

于 2013-07-04T03:57:48.473 回答