我有一个单元测试,根据传递的参数,行为不同.VS 2010 MS测试框架是否具有使用不同参数调用相同测试的功能.我正在寻找这样的东西:
[TestRun(False)]
[TestRun(True)]
[TestMethod]
public void FooTest(bool a)
{
RunTest(a);
}
Run Code Online (Sandbox Code Playgroud) 有谁知道为什么下面的代码不能编译?add()和addAll()都不能按预期工作.删除"?extends"部分会使一切正常,但之后我将无法添加Foo的子类.
List<? extends Foo> list1 = new ArrayList<Foo>();
List<? extends Foo> list2 = new ArrayList<Foo>();
/* Won't compile */
list2.add( new Foo() ); //error 1
list1.addAll(list2); //error 2
Run Code Online (Sandbox Code Playgroud)
错误1:
IntelliJ说:
add(capture<? extends Foo>) in List cannot be applied to add(Foo)
Run Code Online (Sandbox Code Playgroud)
编译器说:
cannot find symbol
symbol : method addAll(java.util.List<capture#692 of ? extends Foo>)
location: interface java.util.List<capture#128 of ? extends Foo>
Run Code Online (Sandbox Code Playgroud)
错误2:
IntelliJ给了我
addAll(java.util.Collection<? extends capture<? extends Foo>>) in List cannot be applied to addAll(java.util.List<capture<? extends Foo>>)
Run Code Online (Sandbox Code Playgroud)
而编译器只是说
cannot find symbol
symbol …Run Code Online (Sandbox Code Playgroud) MySQL 5.1中有如下表:
+--------------+----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------------+------+-----+---------+----------------+
| log_id | int(11) | NO | PRI | NULL | auto_increment |
| date | datetime | NO | MUL | NULL | |
| date_millis | int(3) | NO | | NULL | |
| eib_address | varchar(20) | NO | | NULL | |
| ip_address | varchar(15) | NO | | NULL | |
| value | decimal(20,10) | …Run Code Online (Sandbox Code Playgroud) 我有一个 div,设置了一个 onMouseUp 事件(在 HTML 中)。在那个 div 中有许多元素,其中一些包含我想要拖动的句柄图标。这些图标有一个 onMouseDown 事件。
当我将鼠标放在图标上并释放它时,首先会触发图标的 onMouseDown 事件,然后触发 div 的 onMouseUp 事件 - 正如我所期望的那样。
但是,当我点击图标,将其拖到 div 的另一部分,然后释放时,mouseDown 事件会按您的预期触发,而 onmouseUp 事件不会触发。
我有两个问题。
1)为什么这是这种行为?
2)在浏览器独立方式中处理拖放的正确方法是什么?
我在寡妇上使用 firefox 3.6.16,但 IE 8 的行为方式相同。
关于这个主题已经有几个问题,但我仍然不确定该怎么做:我们的代码库shared_ptr在许多地方使用.我必须承认,在编写时我们没有明确定义所有权.
我们有一些方法
void doSomething(shared_ptr<MyClass> ptr)
{
//doSomething() is a member function of a class, but usually won't store the ptr
ptr->foo();
...
}
Run Code Online (Sandbox Code Playgroud)
在发现了第一个(间接的)循环依赖之后,我想纠正我们设计中的错误.但我不确定如何.从上面改变方法有什么好处
void doSomething(weak_ptr<MyClass> ptr)
{
shared_ptr<MyClass> ptrShared = ptr.lock();
ptrShared->foo();
...
}
Run Code Online (Sandbox Code Playgroud)
?
我也很困惑,因为有些人说(包括谷歌风格指南),首先要确保所有权的正确性(这可能意味着引入许多weak_ptrs,例如在上述方法的例子中,但对许多成员变量也是如此)我们有).其他人说(请参阅下面的链接)你应该使用weak_ptr来打破循环依赖.但是,检测它们并不总是很容易,所以我想我是否真的应该使用shared_ptr,直到我遇到问题(并实现它们),然后修复它们?
谢谢你的想法!
也可以看看
我发现可视状态管理器和触发器之间的功能有一些重叠.
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
... bla bla ...
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Run Code Online (Sandbox Code Playgroud)
或者我可以去
<Trigger Property="IsPressed" Value="true">
... bla bla ...
</Trigger>
Run Code Online (Sandbox Code Playgroud)
我何时应该使用一个与另一个?
我有一个列表L = [[id1,avg1],[id2,avg2],....,[idN,avgN]],我想通过平均排序这个列表.我甚至无法开始编码!任何的想法???
当视图加载并保存带有调用内容的NSMutableArray时,我经常调用Web服务.然后在cellForRowAtIndexPath中,我从这个数组中检索行.我使用感觉像黑客来从indexPath获取行索引,但是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
<snip cell alloc stuff>
// Configure the cell.
unsigned int *indexes = (unsigned int*)calloc( [indexPath length], sizeof( unsigned int ) );
[indexPath getIndexes:indexes];
Tasks *task = [_tasksArray objectAtIndex:indexes[1]];
free( indexes );
cell.textLabel.text = [task getname];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Started: %@", [task getstarted] ? [[task getstarted] description] : @"Not Yet"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?
我正在写一个移动应用程序,我打算允许Facebook帖子.现在,我对我想做的事情感到困惑.
所以我在辩论该怎么做:
我们页面的主要目标是与用户沟通/创建社区意识.
由于选择自定义名称是一个永久的决定,我想听听您对每种方法的利弊的看法.
我想MethodInterceptor在我的模块的configure()方法中绑定一个,如下所示:
public class DataModule implements Module {
@Override
public void configure(Binder binder) {
MethodInterceptor transactionInterceptor = ...;
binder.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), null);
}
@Provides
public DataSource dataSource() {
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:test");
return dataSource;
}
@Provides
public PlatformTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Provides
public TransactionInterceptor transactionInterceptor(PlatformTransactionManager transactionManager) {
return new TransactionInterceptor(transactionManager, new AnnotationTransactionAttributeSource());
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在transactionInterceptorGuice的帮助下获得,或者我是否需要手动创建拦截器所需的所有对象?
java ×2
c++ ×1
duplicates ×1
facebook ×1
firefox ×1
generic-list ×1
generics ×1
guice ×1
ios ×1
javascript ×1
mstest ×1
mysql ×1
objective-c ×1
prolog ×1
shared-ptr ×1
silverlight ×1
sql ×1
unit-testing ×1
wpf ×1
xaml ×1