ActiproSoftware 控件破坏了 Moq 单元测试
ActiproSoftware controls breaks Moq unit tests
Moq 不想在 net core 3.1 上使用 ActiroSoftware
我遇到以下问题:创建具有以下结构的 net core 3.1 项目:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="Actiprosoftware.Controls.WPF" Version="20.1.0" />
</ItemGroup>
</Project>
然后在Program.cs中尝试写下:
using Moq;
namespace moqtest
{
class Program
{
static void Main(string[] args)
{
var q = It.IsAny<string>();
}
}
}
请注意,由于以下错误,这将无法编译:
error CS0234: The type or namespace name 'IsAny' does not exist in the namespace 'It' (are you missing an assembly reference?)
此外,隐式指定命名空间将起作用:
var q = Moq.It.IsAny<string>();
我查看了 msbuild 诊断程序,似乎一切都与 netcoreapp3.1 兼容,但是当你编译它时,它似乎无法识别 It class没有了。
请帮忙!
打开 View > Object Browser
,然后搜索 It
。您会注意到第一个结果是由 ActiproSoftware.BarCode.Wpf.dll
引入的名为 It
的 namespace
它也恰好是一个空的命名空间,但这无关紧要。如果它下面确实包含任何内容,您会将它们称为 It.Something
。所以现在发生的事情是,即使你做了 using Moq
,It
对编译器来说仍然是模棱两可的。
那个愚蠢的空命名空间的存在迫使您使用 Moq.
限定您的调用
Moq 不想在 net core 3.1 上使用 ActiroSoftware
我遇到以下问题:创建具有以下结构的 net core 3.1 项目:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="Actiprosoftware.Controls.WPF" Version="20.1.0" />
</ItemGroup>
</Project>
然后在Program.cs中尝试写下:
using Moq;
namespace moqtest
{
class Program
{
static void Main(string[] args)
{
var q = It.IsAny<string>();
}
}
}
请注意,由于以下错误,这将无法编译:
error CS0234: The type or namespace name 'IsAny' does not exist in the namespace 'It' (are you missing an assembly reference?)
此外,隐式指定命名空间将起作用:
var q = Moq.It.IsAny<string>();
我查看了 msbuild 诊断程序,似乎一切都与 netcoreapp3.1 兼容,但是当你编译它时,它似乎无法识别 It class没有了。
请帮忙!
打开 View > Object Browser
,然后搜索 It
。您会注意到第一个结果是由 ActiproSoftware.BarCode.Wpf.dll
It
的 namespace
它也恰好是一个空的命名空间,但这无关紧要。如果它下面确实包含任何内容,您会将它们称为 It.Something
。所以现在发生的事情是,即使你做了 using Moq
,It
对编译器来说仍然是模棱两可的。
那个愚蠢的空命名空间的存在迫使您使用 Moq.