问题列表 - 第36527页

有没有办法在try/catch块中一般地包装任何函数调用?

我正在为一个项目编写一堆集成测试.我想调用包含在try/catch块中的每个单独的集成点方法,这样当它失败时,我会得到某种反馈来显示,而不是仅仅崩溃应用程序.我还希望能够计算调用的时间,并在需要时检查返回值.所以,我有一个IntegrationResult类,其中包含一些基本描述,结果和时间已过去的属性:

class IntegrationResult
{
  private StopWatch _watch;

  public string Description {get;set;}

  public string ResultMessage {get;set;}

  public bool TestPassed {get;set;}

  public string TimeElapsed {get { return _watch == null ? "0" : _watch.Elapsed.TotalMilliseconds.ToString(); } }

  public void Start()
  {
    _watch = StopWatch.StartNew();
  }  

  public void Stop()
  {
    _watch.Stop();
  }
}
Run Code Online (Sandbox Code Playgroud)

我写的代码看起来像这样:

IntegrationResult result = new IntegrationResult();
result.Description = "T-SQL returns expected results";

    try
    {
      result.Start();
      SomeIntegrationPoint("potential arguments"); //This is the line being tested
      result.Stop();

      //do some check that correct data is …
Run Code Online (Sandbox Code Playgroud)

c# integration-testing exception-handling

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

如何在c#中表示数学变量?

我需要在代码中表示这些数学方程式并解决它们:

2x = 3y
3y = 4z
2x + 3y + 4z = 1
Run Code Online (Sandbox Code Playgroud)

请指教.

c# math

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

如何使用Python的unittest测试是否已经抛出警告?

我在Python中有一个以下函数,我想用unittest测试如果函数得到0作为参数,它会抛出一个警告.我已经尝试过assertRaises,但由于我没有提出警告,这不起作用.

def isZero(i):
    if i != 0:
        print "OK"
    else:
        warning = Warning("the input is 0!") 
        print warning
    return i
Run Code Online (Sandbox Code Playgroud)

python warnings unit-testing exception-handling

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

AppFabric ErrorCode <ERRCA0017> <ES0006>:

我在服务器上安装了AppFabric.我创建了一台计算机的集群.我还创建了一个名为"Gagan"的缓存.按顺序使用以下命令

Use-CacheCluster -Provider xml -ConnectionString\NB-GJANJUA\Cache Start-CacheCluster

结果是缓存服务已启动并运行..这么好.

然后我设置我的web.config文件,如下所示

<?xml version="1.0"?>
<configuration>
    <configSections>
    <section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
        Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
        Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>   

</configSections>

<!-- cache client -->
<dataCacheClient>
<!-- cache host(s) -->

<hosts>
  <host
     name="NB-GJANJUA.com"
     cachePort="22233"/>
</hosts>
</dataCacheClient>

<system.web>    

<compilation debug="true" targetFramework="4.0" >
    <assemblies>
      <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add assembly="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </assemblies>
</compilation>

<sessionState mode="Custom" customProvider="SessionStore" cookieless="true">
  <providers> …
Run Code Online (Sandbox Code Playgroud)

appfabric appfabric-cache

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

iPhone键值编码 - 测试键的存在

iPhone键值编码是否有办法测试一个类是否接受给定的键?

也就是说,如果没有实现目标类的valueForUndefinedKey:或setValue:forUndefinedKey:方法,我希望能够做到这样的事情:

if ([targetObject knowsAboutKey: key])  {
  [targetObject setValue: value forKey: key];
}
Run Code Online (Sandbox Code Playgroud)

iphone key-value-coding

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

Chrome和Safari中与thead的双边距

我有一个table使用theadtbody.在table已经border-spacing设定,并且在浏览器和Safari之间的空间标题行剩余部分被加倍.

据报道,去年年底Chrome出现问题,但这是我能找到的唯一参考资料.

有没有其他人有这个,或知道如何解决它?

<table style="border-spacing: 0 5px">
<thead>
    <tr>
        <th>Heading 1</th>
        <th>Heading 2</th>
        <th>Heading 3</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Cell 1</td>
        <td>Cell 2</td>
        <td>Cell 3</td>
    </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

它在Firefox中按预期显示(所有行等距),不确定IE.

html safari webkit google-chrome html-table

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

Delphi:重载的虚拟构造函数后代未被重载调用

关于Delphi中构造函数的一系列问题还有另一个问题.

我有一个具有虚拟构造函数的基类:

TComputer = class(TObject)
public
    constructor Create(Teapot: Integer); virtual;
end;
Run Code Online (Sandbox Code Playgroud)

构造函数是虚拟的,适合有人需要调用的时间

var
   computerClass: class of TComputer;
   computer: TComputer;
begin     
   computer := computerClass.Create(nTeapot);
Run Code Online (Sandbox Code Playgroud)

构造函数overridden位于后代:

TCellPhone = class(TComputer) 
public
   constructor Create(Teapot: Integer); override;
end;

TiPhone = class(TCellPhone ) 
public
   constructor Create(Teapot: Integer); override;
end;
Run Code Online (Sandbox Code Playgroud)

哪里TCellPhoneTiPhone后代都有机会进行自己的初始化(为了便于阅读而不包括成员).

但是现在我向一些祖先添加了一个重载的构造函数:

TCellPhone = class(TComputer) 
public
   constructor Create(Teapot: Integer); override; overload;
   constructor Create(Teapot: Integer; Handle: string); overload;
end;
Run Code Online (Sandbox Code Playgroud)

TCellPhone中的备用构造函数调用另一个虚拟构造函数,因此它始终获得正确的重写行为:

constructor TCellPhone.Create(Teapot: Integer; Handle: string);
begin
   TCellPhone.Create(Teapot); //call sibling virtual …
Run Code Online (Sandbox Code Playgroud)

delphi constructor delphi-5 constructor-chaining

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

"自由线程"和"线程安全"之间的区别

有时我会看到术语"自由线程"来描述一个类或一个方法.它似乎与"线程安全"具有相似或相同的含义.

这两个术语有区别吗?

multithreading thread-safety

29
推荐指数
2
解决办法
6645
查看次数

从Hudson传递Maven调试标志

我在哈德森的maven构建中遇到了问题.如果我能看到传入-X标志的maven的输出,这个问题就很容易解决.但是我找不到办法做到这一点.如果我在作业配置中"构建"部分的"目标和选项"字段中指定"-X",则我的控制台输出看起来与我根本没有传递"-X"标志完全相同.调试日志记录是否会转移到其他位置?或者还有其他方式我需要传递"-X"标志?

更新:

这不起作用的原因是因为在实际启动真正的maven构建并传入我在项目中指定的任何参数之前,构建在哈德逊过程的"解析POM"部分期间失败了.所以我真正需要的是一种在哈德森的maven构建的"Parsing POM"部分中获得更好记录的方法.

maven-2 hudson

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

如何更改WP7 Silverlight应用程序上的启动页面?

我在我的WP7应用程序中添加了一个新的XAML页面,我需要应用程序在这个新页面上启动.我怎么做 ?

我找不到在App.xaml或App.xaml.cs中任何地方引用的MainPage(这是当前/默认的起始页).

silverlight windows-phone-7

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