小编asa*_*asa的帖子

使用Request.CreateResponse进行ASP.NET WebApi单元测试

我正在尝试为我的ApiController编写一些单元测试并遇到一些问题.有一个很好的扩展方法叫做Request.CreateResponse,可以帮助生成响应.

public HttpResponseMessage Post(Product product)
{
  var createdProduct = repo.Add(product);
  return this.Request.CreateResponse(HttpStatusCode.Created, createdProduct);
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在不使用部分模拟或直接使用"new HttpResponseMessage(...)"的情况下模拟CreateResponse?

c# unit-testing mocking httpresponse asp.net-web-api

144
推荐指数
3
解决办法
5万
查看次数

如何在node.js/nconf中转换/合并配置文件?

我有应用程序设置的node.js应用程序和conf.json文件,即:

{
  "settings": [
    {
      "name": "setting1",
      "connectionString": {
        "host": "mongodb://127.0.0.1:27017/db",
        "collection": "collection1"
      }
    }, 
    {
      "name": "setting2",
      "file": "/path/file",
      "token": "development token"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在nconf或其他工具中使用.NET的配置转换模拟,所以我可能有生成配置文件覆盖,即conf.production.json:

{
  "settings": [
    {
      "name": "setting2",
      "token": "production token"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

生产模式中"setting2"的预期值是"生产令牌",并从默认配置文件中休息.我试图用nconf加载基本文件,但它不起作用:

nconf.file(process.env.NODE_ENV, './conf.' + process.env.NODE_ENV + '.json');
nconf.file('./conf.json');
Run Code Online (Sandbox Code Playgroud)

json config node.js

7
推荐指数
1
解决办法
2009
查看次数

RavenDB:如何使用Multi Maps/Reduce索引

我有一个非常简单的模型:

public class PhraseMeta:
{
 public int Id { get; set; }
 public string ModuleName { get; set; }
 public string Description { get; set; }
 public DateTime ModifiedDate { get; set; }
}

public class Phrase
{
  public int Id { get; set; }
  public int PhraseMetaId { get; set; } //reference to PhraseMeta
  public string Language { get; set; }
  public string Text { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

短语包含一些翻译,PhraseMeta包含几个短语的元信息.我试图找到具有ModuleName和Language的Phrase的文本.据我所知,RavenDB的Multi Maps/Reduce索引功能可以帮助它,而不是使用WhereEntityIs.我的索引是:

public class PhraseEntry
{
  public string MetaId { …
Run Code Online (Sandbox Code Playgroud)

.net mapreduce nosql ravendb

5
推荐指数
1
解决办法
1865
查看次数