问题列表 - 第34645页

.NET单元测试框架,可以处理多个线程的测试

我正在尝试为.NET平台找到一个单元测试框架,它可以处理多个线程的测试.

NUnit不支持跨越线程的测试,因为,例如,不考虑这些线程中的异常.Roy Osherove有一个延伸,但它已经过时了1.

MBUnit允许测试由许多线程同时执行,但是我不知道它是否支持在线程内创建的线程.例如,为了测试并发集合,我希望同时运行不同类型的线程(生产者线程和消费者线程).让多个线程执行相同的测试代码是不够的.

谢谢佩德罗

.net testing multithreading

6
推荐指数
1
解决办法
328
查看次数

确定最佳组合的算法 - Bin Packing

给定一组具有值的项目,确定要包括在集合中的每个项目的数量,使得总值小于或等于给定限制,并且总值尽可能大.

例:

Product A = 4
Product B = 3
Product C = 2
Product D = 5

If Total Capacity = 10.5 , then the combination of B,C,D will be selected.
If Total Capacity = 12.5 , then the combination of A,B,D will be selected.
If Total Capacity = 17 , then the combination of A,B,C,D will be selected.

我正在寻找一种算法(如背包或垃圾箱包装)来确定组合.任何帮助赞赏.

c# packing bin np

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

在XCode 3.2.4升级后进行逻辑测试时出现问题

最近升级到XCode 3.2.4和iOS SDK 4.1导致我的单元测试不再适用于我的iOS项目.该项目目前仅在模拟器上运行,而不是真正的硬件.

我试图创建一个新的空白项目,其中添加了一个总是通过的虚拟测试用例,但它也不起作用,给我这个结果:

处理命令输出时发生内部错误:
- [XCBuildLogCommandInvocationSection setTestsPassedString:]:发送到实例0x20176e320
的无法识别的选择器处理命令输出时发生内部错误:
- [XCBuildLogCommandInvocationSectionRecorder endMarker]:发送到实例0x201257de0的无法识别的选择器

是否有其他人使用XCode 3.2.4和iOS SDK 4.1测试案例有问题?

iphone xcode unit-testing ios4 ios

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

字符串编码

我正在检查iTunes资料库的XML备份中是否存在文件.

如何更改此字符串

E:\Entertainment\Music\Latin\100% Azucar The Best of Celia Cruz & La Sonora Matancera/08 Mi Soncito.mp3

对此

E:/Entertainment/Music/Latin/100%25%20Azucar%20%20The%20Best%20of%20Celia%20Cruz%20&%20La%20Sonora%20Matancera/08%20Mi%20Soncito.mp3

变化:

  1. 空间变为%20
  2. 反斜杠变为正斜杠
  3. %(百分号)变为%25

c# encoding

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

使用静态类/方法依赖项测试类

所以我有一个看起来像这样的课程:

public class MyClassToTest()
{
    MyStaticClass.DoSomethingThatIsBadForUnitTesting();
}
Run Code Online (Sandbox Code Playgroud)

和一个看起来像这样的静态类:

public static class MyStaticClass()
{
    public static void DoSomethingThatIsBadForUnitTesting()
    {
        // Hit a database
        // call services
        // write to a file
        // Other things bad for unit testing
    }
}
Run Code Online (Sandbox Code Playgroud)

(显然这是一个愚蠢的例子)

所以,我知道第二类在单元测试方面注定要失败,但有没有办法解开MyClassToTest类,以便我可以测试它(没有实例化MyStaticClass).基本上,我希望它忽略这个电话.

注意:遗憾的是这是一个Compact Framework项目,因此不能使用Moles和Typemock Isolator等工具:(.

c# static unit-testing mocking

9
推荐指数
1
解决办法
2694
查看次数

Windows Service通过HTTPS托管WCF

我已根据MSDN的这些说明创建并配置了SSL证书.我收到此问题列出的错误消息,但不知道如何将该问题中接受的答案映射到我的App.config文件.配置文件的内容和服务本身在http上正常工作,只是在https上发生了问题.

我的App.config文件目前是:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="LookupServiceHost" behaviorConfiguration="serviceBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:54321/MyService"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="ILookupService" bindingConfiguration="TransportSecurity" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehaviour">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Windows事件日志中返回的错误异常:

服务无法启动.System.ServiceModel.AddressAlreadyInUseException:HTTP无法注册URL https:// +:54321/MyService /.另一个应用程序已经使用HTTP.SYS注册了此URL.---> System.Net.HttpListenerException:无法侦听前缀' https:// +:54321/MyService / ',因为它与计算机上的现有注册冲突.

有人可以给我一个指针,说明如何启用它?

c# wcf windows-services

19
推荐指数
1
解决办法
2万
查看次数

如何做我自己的自定义运行时错误类?

我正在尝试做一个简单的自定义runtime_error.我定义了这个类:

#include <string>
#include <stdexcept>


namespace utils{

 class FileNotFoundException: public std::runtime_error{
  public:
   FileNotFoundException():runtime_error("File not found"){}
   FileNotFoundException(std::string msg):runtime_error(msg.c_str()){}
 };

};
Run Code Online (Sandbox Code Playgroud)

然后我抛出错误:

bool checkFileExistence( std::string fileName )
 {
  boost::filesystem::path full_path = boost::filesystem::system_complete(boost::filesystem::path(fileName));
  if (!boost::filesystem::exists(full_path))
  {
    char msg[500];
    _snprintf(msg,500,"File %s doesn't exist",fileName.c_str());
    throw new FileNotFoundException(msg);
  }
 }
Run Code Online (Sandbox Code Playgroud)

我使用try/catch块

    try{
          checkFileExistence(fileName);
     }
   catch(utils::FileNotFoundException& fnfe)
        {
          std::cout << fnfe.what() << std::endl;
     }
Run Code Online (Sandbox Code Playgroud)

运行时错误被正确抛出为FileNotFoundException,但是从未到达带有std :: cout的行,并且没有行被写入控制台.

欢迎所有想法.谢谢!

c++ exception

7
推荐指数
2
解决办法
6805
查看次数

jQuery从列表中获得最大数量

var one = 1415;
var two = 2343;
var three = 11;
Run Code Online (Sandbox Code Playgroud)

如何从这些变量中获得最大数量?

javascript variables jquery

8
推荐指数
2
解决办法
1万
查看次数

为什么图像的流媒体源不起作用?

我使用以下代码来流式传输图像源:

        BitmapImage Art3 = new BitmapImage();
        using (FileStream stream = File.OpenRead("c:\\temp\\Album.jpg"))
        {
            Art3.BeginInit();
            Art3.StreamSource = stream;
            Art3.EndInit();
        }
        artwork.Source = Art3;
Run Code Online (Sandbox Code Playgroud)

"artwork"是应该显示图像的XAML对象.该代码不应该锁定图像,它不会将其锁定好,但也不显示它,默认图像变为"无"......我的猜测是我没有正确使用流,并且我的图像变为空.救命?

更新:

我现在使用以下代码,朋友向我建议:

        BitmapImage Art3 = new BitmapImage();

        FileStream f = File.OpenRead("c:\\temp\\Album.jpg");

        MemoryStream ms = new MemoryStream();
        f.CopyTo(ms);
        f.Close();

        Art3.BeginInit();
        Art3.StreamSource = ms;
        Art3.EndInit();   

        artwork.Source = Art3;
Run Code Online (Sandbox Code Playgroud)

由于某些奇怪的原因,此代码返回以下错误:

图像无法解码.图像标头可能已损坏.

我究竟做错了什么?我确信我试图加载的图像没有损坏.

c# wpf image stream

7
推荐指数
2
解决办法
8530
查看次数

java反射调用已加载对象的方法

如何使用反射调用已在JVM中加载的对象的方法?我试过了

Class myClass = Class.forName("myClass");
Method m = com.test.class.getDeclaredMethod("getValue",new Class[] {});
Object result = m.invoke(myClass,null);
Run Code Online (Sandbox Code Playgroud)

但我得到java.lang.IllegalArgumentException:object不是声明类的实例.我想调用的方法是void,即不接受参数

更新 我有一个已加载类"A"的应用程序.另一个类"B"将由框架实例化.初始化类"B"时,类"A"已经加载到JVM中.我想从类"A"BUT的加载实例中调用一个方法而不在类"B"中引用"A".在答案中,似乎我必须在类"B"中创建一个"A"的新实例,但我想要访问已经加载的对象.如果我在"B"中创建"A"的新实例,为什么我要使用反射?我想念一些东西吗?

谢谢

java reflection jvm classloader

4
推荐指数
2
解决办法
2万
查看次数