我经常使用Rhino Mocks 3.5,但最近遇到过我从未尝试过的东西.我想存根一个服务并设置返回值 - 真的很简单
唯一的问题是,现在我的服务不是返回IList,而是返回IQueryable
所以,当我尝试做这样的事情时 - 它会爆炸
<TestMethod()> _
Public Sub Should_Populate_Users_Property_On_View_During_OnInit()
Dim View As IUserView = MockRepository.GenerateStub(Of IUserView)()
Dim Service As IUserService = MockRepository.GenerateStub(Of IUserService)()
Dim Presenter As New UserPresenter(View, Service)
Dim StubUserObjectCollection As New List(Of User)
StubUserObjectCollection.Add(New User(1, "jdoe", "John", "Doe", 0, 0, 0, 1, 1))
Service.Stub(Function(x) x.GetUserCollection()).[Return](StubUserObjectCollection)
Presenter.OnViewInit()
Assert.AreEqual(View.Users.Count, 1)
End Sub
Run Code Online (Sandbox Code Playgroud)
如何将服务存根以便为下面的单元测试启用(为简洁而保持简单)
Public Sub OnViewInit()
Dim UserList As List(Of User) = mUserService.GetUserCollection.Where(Function(x) x.Active = 1).OrderBy(Function(x) x.FirstName).ToList()
mView.Users = UserList
End Sub
Run Code Online (Sandbox Code Playgroud) 我有以下正则表达式,需要1个数字,1个字母上部和1个字母下部(w /最少8个长度)
Regex.IsMatch(password, "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}$")
Run Code Online (Sandbox Code Playgroud)
我需要添加另一个过滤器以确保存在以下特殊字符之一(任何帮助?)
#, $, @, !, %, &, * ?
Run Code Online (Sandbox Code Playgroud) 最初,当我学习如何编写多视图应用程序时,我发现了这种重新加载UITableView的方法
[randomTableView reloadData];
但是当我想重新加载MKMapView时,我该怎么做呢?场景是这样的:
我选择一个地址并加载地图(点击所有常用的控制器方法 - 生活很好)接下来我"回"并点击另一个地址(但地图仍然显示以前的位置)
先感谢您!
我正在动态构建一个url,并且需要一种方法来将NSNumber的intValue添加到它的末尾.
NSNumber *hatId = [NSNumber NumberWithInt:25]
NSMutableString* theUrlString = [[NSMutableString alloc] init];
[theUrlString appendFormat:@"http://www.website.com/SelectHat/%d", [hatid intValue]];
NSURL *url = [NSURL URLWithString:theUrlString];
Run Code Online (Sandbox Code Playgroud)
完成上述操作后,一个简单的单元测试或NSLog将显示结果看起来有效
http://www.website.com/SelectHat/25
但我的问题是这样 - 以这种方式连接是否会改变NSString所以它不会像我期望的那样有效的字符串?这也是构建需要来自NSNumber的intValue的字符串的"好"方法吗?
更新
我只想确保%d内联没有问题,NSString就像我预期的那样.我遇到的问题有点复杂,所以我会将其保存为另一个问题.感谢关于NSURL/NSNumber/int的回复,因为我还在学习很多关于objective-c的知识
我将我的活动中的Web服务调用推送到一个线程(如下所示).我第一次在活动中这样做它工作正常(从我的edittext获取文本并加载服务以获取lat/lng数据)
但是,当我单击后退按钮(模拟器)并尝试在.start()之后第二次触发此线程时 在我的点击处理程序中 我在这里做错了什么?谢谢
private Thread getLocationByZip = new Thread() {
public void run() {
try {
EditText filterText = (EditText) findViewById(R.id.zipcode);
Editable zip = filterText.getText();
LocationLookupService locationLookupService = new LocationLookupService();
selectedLocation = locationLookupService.getLocationByZip(zip.toString());
locationHandler.post(launchFindWithLocationInfo);
} catch (Exception e) {
}
}
};
private Runnable launchFindWithLocationInfo = new Runnable() {
@Override
public void run() {
try {
Intent abc = new Intent(LocationLookup.this, FindWithLocation.class);
startActivity(abc);
} catch (Exception e) {
}
}
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
locationHandler …Run Code Online (Sandbox Code Playgroud) 我正在比较ember.js和angularJS以及我最喜欢的ember目前是Router和ember-data(很快就会成为我希望的核心框架的一部分).
有谁知道angularJS是否支持这两个功能?
我有一个基于简单键映射调用的函数
function! JumpToDefinition()
let filetype=&ft
if filetype == 'coffee'
exe '<C-]>'
endif
endfunction
Run Code Online (Sandbox Code Playgroud)
当我手动执行此操作<C-]>时,但当我尝试"exe"它上面时,我得到一个"尾随空格"错误.
如何在我上面的独立函数中调用它?
我正在尝试删除应用于bootstrap 3.0.3中所有锚标签的悬停.这是我的基本结构
<ul class="nav affix-top">
<li class="menu-text"><a href="#">hello</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我尝试过使用!在我的CSS中很重要,但到目前为止还没有运气
.menu-text a:hover {
background-color: none !important;
}
Run Code Online (Sandbox Code Playgroud) 我有一个连接几次的简单功能
return config.load()
.then(function() {
//first duplicate code block
})
.then(function() {
//the start of my unique block
return foo.bar()
.then(function(trace) {
//unique code
})
.then(function(tree) {
//more unique code
});
})
.then(function() {
//second duplicate code
})
.then(config.save)
.then(function() {
//more duplicate for part 2
})
.catch(function(e) {
//more duplicate for part 2
});
Run Code Online (Sandbox Code Playgroud)
你在上面看到的中间"那么"是我在两个不同情况下唯一不同的部分.我正在寻找如何重构它以保持干燥
我注意到通用错误控制器在json的404响应中返回响应中的路径(由用户提供),我想要一个覆盖来配置它.
到目前为止,我已经关闭了基本的白标
error.whitelabel.enabled = FALSE
然后我配置了自己的控制器来处理/错误路径但是...当我去运行应用程序时,springboot试图"连接"另一个BasicErrorController导致异常
如果我想正式覆盖404页面(沿着w /其他http响应类型,如application/json),我该如何使用springboot执行此操作?
iphone ×2
objective-c ×2
android ×1
angularjs ×1
ember.js ×1
java ×1
javascript ×1
linq ×1
mkmapview ×1
regex ×1
rhino-mocks ×1
spring-boot ×1
unit-testing ×1
vim ×1