我正在为一个项目编写一堆集成测试.我想调用包含在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) 我需要在代码中表示这些数学方程式并解决它们:
2x = 3y
3y = 4z
2x + 3y + 4z = 1
Run Code Online (Sandbox Code Playgroud)
请指教.
我在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) 我在服务器上安装了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) iPhone键值编码是否有办法测试一个类是否接受给定的键?
也就是说,如果没有实现目标类的valueForUndefinedKey:或setValue:forUndefinedKey:方法,我希望能够做到这样的事情:
if ([targetObject knowsAboutKey: key]) {
[targetObject setValue: value forKey: key];
}
Run Code Online (Sandbox Code Playgroud) 我有一个table使用thead和tbody.在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.
关于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)
哪里TCellPhone和TiPhone后代都有机会进行自己的初始化(为了便于阅读而不包括成员).
但是现在我向一些祖先添加了一个重载的构造函数:
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) 有时我会看到术语"自由线程"来描述一个类或一个方法.它似乎与"线程安全"具有相似或相同的含义.
这两个术语有区别吗?
我在哈德森的maven构建中遇到了问题.如果我能看到传入-X标志的maven的输出,这个问题就很容易解决.但是我找不到办法做到这一点.如果我在作业配置中"构建"部分的"目标和选项"字段中指定"-X",则我的控制台输出看起来与我根本没有传递"-X"标志完全相同.调试日志记录是否会转移到其他位置?或者还有其他方式我需要传递"-X"标志?
更新:
这不起作用的原因是因为在实际启动真正的maven构建并传入我在项目中指定的任何参数之前,构建在哈德逊过程的"解析POM"部分期间失败了.所以我真正需要的是一种在哈德森的maven构建的"Parsing POM"部分中获得更好记录的方法.
我在我的WP7应用程序中添加了一个新的XAML页面,我需要应用程序在这个新页面上启动.我怎么做 ?
我找不到在App.xaml或App.xaml.cs中任何地方引用的MainPage(这是当前/默认的起始页).
c# ×2
appfabric ×1
constructor ×1
delphi ×1
delphi-5 ×1
html ×1
html-table ×1
hudson ×1
iphone ×1
math ×1
maven-2 ×1
python ×1
safari ×1
silverlight ×1
unit-testing ×1
warnings ×1
webkit ×1