我最近安装了VS2012并开始处理我曾经使用VS2010的工作项目.我从来没有遇到VS2010没有识别asp前缀标签的问题,但VS2012是.我试着删除下面的ReflectedSchemas文件夹
C:\用户[用户名] \应用程序数据\漫游\微软\ VisualStudio的\ 11.0 \
但仍然没有工作.有没有人在VS2012遇到过这个问题?
在我的单元测试中,我希望能够在我的工作单元中使用lambda express来获取我的存储库的"查找"功能.例如:
public virtual IQueryable<T> Find(Expression<Func<T, bool>> predicate)
{
// Find OPS
}
Run Code Online (Sandbox Code Playgroud)
我在单元测试中创建了测试列表以表示我的dbSets(同样,我省略了很多抽象,以使这个问题更加简单):
[TestMethod]
public void FindTest()
{
var mockUnitOfWork = new Mock<IUnitOfWork>();
var testList = new List<ListObject>
{
// Test values
}
// Here is where I am stuck:
mockUnitOfWork.Setup(uow => uow.Find(It.IsAny<Expression<Func<ListObject, bool>>>()))
.Returns(/* ???? testList.Where(??????) ???? */);
}
Run Code Online (Sandbox Code Playgroud)
我希望能够使用调用mock的find的方法传递的lambda来在我的模拟列表中进行搜索.这可能吗?
编辑:感谢克里斯的回答.这是设置代码,用于传递由引用模拟函数的方法传递的lambda表达式:
mockUnitOfWork
.Setup(uow => uow.Find(It.IsAny<Expression<Func<ListObject, bool>>>()))
.Returns(new Func<Expression<Func<ListObject, bool>>, IQueryable<ListObject>>(
expr => testList.Where(expr.Compile()).AsQueryable()));
Run Code Online (Sandbox Code Playgroud) 通过javascript我如何在下拉菜单中添加更多选项?
目前尝试以下运气没有运气:
for (i = 0; i < json.powerDropDownItems.length; i++) {
//$('#powerSelect').append($("<option></option>").attr("value", json.powerDropDownItems[i]).text(json.powerDropDownItems[i]));
$('#powerSelect').selectmenu("value", "nice name");
//$('#powerSelect').appendTo("<option>" + json.powerDropDownItems[i] + "</option>");
}
$('#powerSelect').selectmenu("refresh");?
Run Code Online (Sandbox Code Playgroud)
UPDATE
感谢naveen,我得到了它的工作(还添加了清除列表的代码).这是我的以下代码:
service.getPowerDropDowns(productEC, $('#mountSelect').val(), function (response) {
var json = $.parseJSON(response.value);
var options = [];
// Clear the options first
$("#powerSelect option").each(function(index, option) {
$(option).remove();
});
options.push("<option value=''>Choose</option>");
for (i = 0; i < json.powerDropDownItems.length; i ++)
{
options.push("<option value='" + json.powerDropDownItems[i] + "'>" + json.powerDropDownItems[i] + "</option>");
}
$('#powerSelect').append(options.join("")).selectmenu();
$('#powerSelect').selectmenu('enable');
});
Run Code Online (Sandbox Code Playgroud)