我想从这样的控制台运行测试(在任何目录中,dll可以是不同的.NET版本):
$ nunit3-console test.dll
Run Code Online (Sandbox Code Playgroud)
我google了很多,但找不到如何设置这个.官方教程没有任何用处,完全为零,跟随它让我无处可去:https://github.com/nunit/docs/wiki/Installation
1.启动应用程序时出错
Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.Web.Http.GlobalConfiguration..cctor() +0
[TypeInitializationException: The type initializer for 'System.Web.Http.GlobalConfiguration' threw an exception.]
System.Web.Http.GlobalConfiguration.get_Configuration() +14
SerilogWeb.Classic.WebApi.PreApplicationStartModule.Register() +10
[InvalidOperationException: The pre-application start initialization method Register on type SerilogWeb.Classic.WebApi.PreApplicationStartModule threw an exception with the following error …Run Code Online (Sandbox Code Playgroud) 我有要映射的类,但它们没有默认的构造函数,我不希望它们有.这是因为我只映射到现有对象/从现有对象映射.
public class Order
{
public string OrderName { get; set; }
public Order(string name)
{
this.OrderName = name;
}
}
public class OrderProcessor
{
private IService service;
public string OrderName { get; set; }
public OrderProcessor(IService service)
{
this.service = service;
Mapper.Initialize(config => config.CreateMap<Order, OrderProcessor>());
}
public void Init()
{
var order = this.service.GetOrder();
// this works
Mapper.Map(order, this);
// this fails
Mapper.Configuration.AssertConfigurationIsValid();
}
}
Run Code Online (Sandbox Code Playgroud)
AutoMapper.AutoMapperConfigurationException:找到未映射的成员.查看下面的类型和成员.添加自定义映射表达式,忽略,添加自定义解析程序或修改源/目标类型对于无匹配的构造函数,添加无参数ctor,添加可选参数或映射所有构造函数参数
订单 - > OrderProcessor(目标成员列表)
没有可用的构造函数.
在Tests.cs中的Test():行
当我不想创建新对象时,如何使配置断言传递以及失败的原因?
Resharper 2016.2
当前格式
IEnumerable<Customer> customers = dbCustomers.Select(customer => new Customer
{
Name = customer.Name,
Address = customer.Address,
Number = customer.Number
});
Run Code Online (Sandbox Code Playgroud)
预期的格式
IEnumerable<Customer> customers = dbCustomers.Select(customer => new Customer
{
Name = customer.Name,
Address = customer.Address,
Number = customer.Number
});
Run Code Online (Sandbox Code Playgroud)
哪个Resharper 2016.2配置可以解决这个问题?
请注意,初始化器位于参数括号内,而不是变量.
如何访问Request.Properties的ActionExecutingContext?
public class UserFilter : ActionFilterAttribute
{
public void OnActionExecuting(ActionExecutingContext actionContext)
{
// Properties is not part of the Request here, so I can't access it
// Here Request is of type System.Web.HttpRequestBase
actionContext.HttpContext.Request.Properties.Add("UserData", new UserData());
}
}
Run Code Online (Sandbox Code Playgroud)
我可以做到ApiController:
public class HomeController : ApiController
{
public HomeController()
{
// Here I can do it (here Request is of type
// System.Net.Http.HttpRequestMessage
this.Request.Properties.Add("UserData", new UserData());
}
}
Run Code Online (Sandbox Code Playgroud) 我在'组'节点.从中,我想找到这样的'item'节点,其'id'属性等于当前'group'节点'ref_item_id'属性值.所以在我的情况下,通过在'组'节点B中,我想要'item'节点A作为输出.这有效:
<xsl:value-of select="preceding-sibling::item[@id='1']/@description"/>
Run Code Online (Sandbox Code Playgroud)
但这不会(什么都不给):
<xsl:value-of select="preceding-sibling::item[@id=@ref_item_id]/@description"/>
Run Code Online (Sandbox Code Playgroud)
当我输入:
<xsl:value-of select="@ref_item_id"/>
Run Code Online (Sandbox Code Playgroud)
我的结果是"1".所以这个属性肯定是可访问的,但我无法从上面的XPath表达式中找到它的路径.我尝试了许多'../'组合,但无法让它工作.
要测试的代码:http://www.xmlplayground.com/7l42fo
完整的XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item description="A" id="1"/>
<item description="C" id="2"/>
<group description="B" ref_item_id="1"/>
</root>
Run Code Online (Sandbox Code Playgroud)
完整的XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no"/>
<xsl:template match="root">
<xsl:for-each select="group">
<xsl:value-of select="preceding-sibling::item[@id=@ref_item_id]/@description"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud) c# ×5
.net ×3
asp.net ×1
asp.net-mvc ×1
automapper ×1
automapper-5 ×1
gac ×1
nunit ×1
nunit-3.0 ×1
resharper ×1
unit-testing ×1
xpath ×1
xslt ×1