我有这个:
Expect.Once.On( someObj ).Method( "SomeMethod" )
.With(1) // correct value is 2, I want this to fail
.Will( Throw.Exception( new Exception() ) );
Run Code Online (Sandbox Code Playgroud)
当nmock检测到我输入1而不是2时,会抛出异常.但是,测试失败(红色)而不是传递.即使我期待例外,如何使这个测试通过?
以下是失败的集成测试的伪代码:
[测试]
void TestLogger()
// Init static logger
Logger.Init(pathToFile);
// Create five threads that will call LogMessages delegate
for i = 1 to 5
{
Thread aThread = new Thread(LogMessages)
aThread.Start(i);
}
// let threads complete their work
Thread.Sleep(30000);
/// read from log file and count the lines
int lineCount = GetLineCount();
// 5 threads, each logs 5 times = 25 lines in the log
Assert.Equal(25, lineCount);
static void LogMessages( object data )
// each thread will log five messages …Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法确保PDF在浏览器中是"只读"的,无论与PDF本身绑定的权限设置如何.这是一个可能的场景.有人在我的网站上传了一个PDF,在权限方面是敞开的.作为开发人员,我是否有办法阻止用户下载,打印,保存或截取屏幕截图?换句话说,我希望用户能够在浏览器中"阅读"PDF,但无法下载,打印或保存或截屏它.
(我在MVC环境中使用C#.Net.)
想要将名称值对加载到TStringList中.
有一个包含数据的文本文件:
a=ant
a=animal
b=bob
d=darn
Run Code Online (Sandbox Code Playgroud)
加载它的功能:
LoadData(argPath: string): TStringList;
var
data: TStringList;
begin
data := TStringList.Create(true);
data.Delimiter := '=';
try
data.LoadFromFile(argPath);
except on E : Exception do
begin
Application.MessageBox(PWideChar(E.Message),
'Unable to Load Data', MB_OK or MB_ICONERROR);
Application.Terminate;
end;
end;
Result := data;
end;
Run Code Online (Sandbox Code Playgroud)
结果目前是:
a=ant
a=animal
b=bob
d=darn
Run Code Online (Sandbox Code Playgroud)
希望结果的字符串是:
ant
animal
bob
darn
Run Code Online (Sandbox Code Playgroud)
和结果的TObjects
a
a
b
d
Run Code Online (Sandbox Code Playgroud)
在此之后,我希望能够在TComboBox中显示它.
.net-2.0 ×2
c# ×2
.net ×1
delphi ×1
delphi-xe4 ×1
download ×1
nmock ×1
pdf ×1
printing ×1
tstringlist ×1
unit-testing ×1