从终端运行单元测试的 vstest.console.exe 和 dotnet test 命令之间有什么区别吗?就像什么时候应该使用其中一种而不是另一种。“vstest.console.exe”仅适用于 .Net 框架,而“dotnet test”适用于 dotnet 核心项目吗?我在谷歌或微软的文档中找不到解决这个问题的任何具体答案。
下面链接中的问题很接近,但答案没有解决差异。我想使用脚本在构建服务器中运行我的 C# 项目,并且想知道哪个是最好的选择。
我一直在练习如何使用 SOLID 编写干净的代码。我还在代码中使用 DI 来消除耦合,但只能通过构造函数注入。在我使用过 DI 的很多情况下,我只是用它来调用方法。我还不明白的是,当您有一个依赖类,其构造函数在另一个类中接受参数时,如何解耦。如果var obj = new A(month)在 B 类内部创建依赖关系和紧密耦合,我如何解耦/抽象它?这就是属性接口的用武之地吗?如果是这样,我该如何在这里使用它?
public class A
{
private string _month;
public A(string month)
{
_month = month;
}
}
public class B
{
public List<A> ListOfMonths;
public B()
{
ListOfMonths = new List<A>();
}
public List<A> SomeMethod()
{
string[] months = new []
{
"Jan",
"Feb",
"Mar"
};
foreach(var month in months)
{
var obj = new A(month); // If this is coupling, how do I remove it? …Run Code Online (Sandbox Code Playgroud)