问题列表 - 第27146页

EasyMock vs Mockito:设计与可维护性?

思考这个的一种方法是:如果我们关心代码的设计则EasyMock的是更好的选择,因为它通过它的期望概念,让反馈给您.

如果我们关心的测试可维护性(更容易读,写和具有不会受到太大变化不太脆测试),那么似乎的Mockito一个更好的选择.

我的问题是:

  • 如果您在大型项目中使用过EasyMock,您是否发现您的测试难以维护?
  • Mockito有什么限制(除了endo测试)?

easymock mockito

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

如何过滤J中的列表?

我目前正在学习迷人的J编程语言,但有一点我无法弄清楚如何过滤列表.

假设我有任意列表3 2 2 7 7 2 9,我想删除2s,但保持其他一切不变,即我的结果将是3 7 7 9.我怎么做到这一点?

j tacit-programming

19
推荐指数
3
解决办法
1557
查看次数

TreeMap按值排序

我想写一个比较器,让我按值而不是默认的自然顺序对TreeMap进行排序.

我试过这样的东西,却找不到出了什么问题:

import java.util.*;

class treeMap {
    public static void main(String[] args) {
        System.out.println("the main");
        byValue cmp = new byValue();
        Map<String, Integer> map = new TreeMap<String, Integer>(cmp);
        map.put("de",10);
        map.put("ab", 20);
        map.put("a",5);

        for (Map.Entry<String,Integer> pair: map.entrySet()) {
            System.out.println(pair.getKey()+":"+pair.getValue());
        }
    }
}

class byValue implements Comparator<Map.Entry<String,Integer>> {
    public int compare(Map.Entry<String,Integer> e1, Map.Entry<String,Integer> e2) {
        if (e1.getValue() < e2.getValue()){
            return 1;
        } else if (e1.getValue() == e2.getValue()) {
            return 0;
        } else {
            return -1;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我想我要问的是:我可以Map.Entry传递给比较器吗?

java

124
推荐指数
6
解决办法
24万
查看次数

2个列表之间的常见元素比较

def common_elements(list1, list2):
    """
    Return a list containing the elements which are in both list1 and list2

    >>> common_elements([1,2,3,4,5,6], [3,5,7,9])
    [3, 5]
    >>> common_elements(['this','this','n','that'],['this','not','that','that'])
    ['this', 'that']
    """
    for element in list1:
        if element in list2:
            return list(element)
Run Code Online (Sandbox Code Playgroud)

到目前为止,但似乎无法让它工作!

有任何想法吗?

python list

109
推荐指数
9
解决办法
21万
查看次数

带有RIA服务的实体框架,Silverlight - 脱钩与快速开发的权衡

我最近一直在玩Entity Framework,WCF RIA Services和Silverlight 4.我对使用这些工具开发应用程序的速度感到印象深刻,并且你获得了很多"免费",例如Silverlight UI自动了解EF模型中作为DataAnnotations包含的某些验证.但是,在大型应用程序中,似乎不希望在整个应用程序(包括业务逻辑和UI)中一直推动EF的依赖.

我知道您可以将POCO/IPOCO与实体框架一起使用,这对我来说无疑是一个选择.但是,如果你走这条路,就会失去一些"自动化"的东西,比如Silverlight能够在没有任何额外工作的情况下显示模型验证.

人们如何处理这个问题?你是否放弃了一些功能并将接口放在不同的层之间,以便将其他层与EF分离?或者你是否放弃了解耦以便更快地发展?有没有办法让我的蛋糕吃掉,我没有看到?

silverlight tdd entity-framework wcf-ria-services

3
推荐指数
1
解决办法
590
查看次数

从列表中逐步删除元素

我有一个浮点数列表,我想在给定的索引范围内逐步删除一组元素,sth.喜欢:

for j in range(beginIndex, endIndex+1):
   print ("remove [%d] => val: %g" % (j, myList[j]))
   del myList[j]
Run Code Online (Sandbox Code Playgroud)

但是,由于我在同一个列表上进行迭代,因此新列表的索引(范围)不再有效.有没有人对如何正确删除元素有一些建议?

最好的祝愿

python list

3
推荐指数
1
解决办法
169
查看次数

Firefox无法正确布局嵌套表格?

我想实现一个可折叠的菜单.我计划使用表组件来模拟菜单,并将子表嵌套到表格单元格中以模拟子菜单.

下面是我的代码,它在IE,Chrome和Safari中按预期工作,但它在Firefox中不能很好地工作:

<html>
<body>
<div id="menu" style="position:absolute; left:150px; top:100px; z-index:1">
  <table width="200px" height="90" border=1 cellpadding="0" cellspacing="0">
    <tr> 
      <td colspan=2>Money</td>
    </tr>
    <tr> 
      <td colspan=2>Tool</td>
    </tr>
    <tr> 
      <td>Food
        <table style="position:absolute; left:200px; top:60px; z-index:1" width="200px" height="60px" border="1" cellpadding="0" cellspacing="0">
          <tr> 
            <td>Cookie</td>
          </tr>
          <tr> 
            <td>Fruit
              <table style="position:absolute; left:200px; top:30px; z-index:1" width="200px" height="60px" border="1" cellpadding="0" cellspacing="0">
                <tr> 
                  <td>Apple</td>
                </tr>
                <tr> 
                  <td>Banana</td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

似乎Firefox认为3级菜单的"left"和"top"属性是相对于1级菜单的,所以它错误地布置了3级菜单.其他浏览器将在2级菜单上计算偏移量,这可以按预期工作.

这是Firefox中的错误吗?如果是这样,我该如何解决呢?我希望我的代码在所有主流浏览器中都具有相同的行为.

html javascript css firefox

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

org.hibernate.PropertyNotFoundException

嗨,我是新手hibernate,我使用以下代码,并得到以下错误

public class OperProfile {
private String empId;
 private long age;
 private String name;
public long getAge() {
  return age;
 }
 public void setAge(long age) {
  this.age = age;
 }
public String getEmpId() {
  return empId;
 }
 public void setEmpId(String empId) {
  this.empId = empId;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
}
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

org.hibernate.PropertyNotFoundException:在com.fmr.OperProfile类中找不到年龄的getter

我的hbm.xml文件是

<hibernate-mapping>
 <class name="com.fmr.OperProfile" table="EMPLOYEE"
  dynamic-update="true">

  <id name="empId" type="java.lang.String" column="EMP_ID">
   <generator class="assigned" />
  </id>
  <property …
Run Code Online (Sandbox Code Playgroud)

java hibernate

0
推荐指数
1
解决办法
2819
查看次数

如何设置部署选项以编写Visual Studio 2010数据库项目的增量版本?

我刚刚开始使用VS2010数据库项目来管理现有数据库更新的发布.

我希望部署选项生成一个脚本,该脚本将包含更改现有数据库的命令,而不是创建一个全新的数据库.

例如,我有10个现有表 - 其中一个我放入新版本,我创建了一些新的sprocs.我只希望部署脚本Drop表和Create Procedure命令.

我正在使用VS2010 Premium.

在初始创建到增量发布的项目中,是否存在我可以遵循的推荐标准方法来管理数据库?

谢谢!

database sql-server visual-studio-2010 visual-studio

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

Valgrind'噪音',这是什么意思?

当我使用valgrind帮助调试我正在研究的应用程序时,我注意到大量的噪音似乎在抱怨标准库.作为测试,我做到了这一点;

echo 'int main() {return 0;}' | gcc -x c -o test -
Run Code Online (Sandbox Code Playgroud)

然后我做了这个;

valgrind ./test

==1096== Use of uninitialised value of size 8
==1096==    at 0x400A202: _dl_new_object (in /lib64/ld-2.10.1.so)
==1096==    by 0x400607F: _dl_map_object_from_fd (in /lib64/ld-2.10.1.so)
==1096==    by 0x4007A2C: _dl_map_object (in /lib64/ld-2.10.1.so)
==1096==    by 0x400199A: map_doit (in /lib64/ld-2.10.1.so)
==1096==    by 0x400D495: _dl_catch_error (in /lib64/ld-2.10.1.so)
==1096==    by 0x400189E: do_preload (in /lib64/ld-2.10.1.so)
==1096==    by 0x4003CCD: dl_main (in /lib64/ld-2.10.1.so)
==1096==    by 0x401404B: _dl_sysdep_start (in /lib64/ld-2.10.1.so)
==1096==    by 0x4001471: _dl_start (in /lib64/ld-2.10.1.so)
==1096==    by …
Run Code Online (Sandbox Code Playgroud)

c linux gcc valgrind

11
推荐指数
2
解决办法
1090
查看次数