例如:我有一个属性和方法的接口.该方法使用属性的值来执行某些操作.如何设置模拟以访问属性的值?
interface myInterface
{
Id{get;set;}
string ReturnIdAsString();
}
Mock<myInterface> mock = new Mock<myInterface>();
mock.Setup(m => m.Id).Returns(1);
mock.Setup(m => m.ReturnsIdAsString).Returns(**would like to return m.Id here**);
mock.Object.ReturnsIdAsString(); //should return the value in m.Id
Run Code Online (Sandbox Code Playgroud)
如何设置ReturnsIdAsString来访问属性Id?
我在一个单元中声明了一个类,它需要使用特定的位图.它在我的测试单元的DFM中声明如下:
object ImgTop: TImage
Left = 208
Top = 568
Width = 777
Height = 41
Picture.Data = {
0A544A504547496D616765A1CF0000FFD8FFE000104A46494600010101025802
[truncated]
};
Run Code Online (Sandbox Code Playgroud)
但在我的最后一个单元中,我不会有dfm.那么有什么方法可以在我的单位中声明它?
===
谢谢,我现在似乎已经开始工作,关于位图的大小限制很可怜:(这就是我所做的:
在我的文件夹中是这些文件:
imgleft.bmp
imgtop.bmp
Run Code Online (Sandbox Code Playgroud)
这是我的名为ScanOCRres.rc的资源文件:
1 RT_BITMAP "imgtop.bmp"
2 RT_BITMAP "imgleft.bmp"
Run Code Online (Sandbox Code Playgroud)
我已将其设置为使用C:\ Program Files\Borland\Delphi 7\bin\brcc32.exe自动执行
它生成了该文件
ScanOCRres.RES
Run Code Online (Sandbox Code Playgroud)
在我的单位,我有实施
{$R *.dfm}
{$R ScanOCRres.RES}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var
abmp : TBitmap;
begin
abmp := TBitmap.create;
abmp.LoadFromResourceID(SysInit.HInstance, 1);
abmp.free;
end;
Run Code Online (Sandbox Code Playgroud)
我在LoadFromResourceID行上收到此错误消息:
项目Project1.exe引发了异常类EAccessViolation,并在模块"Project1.exe"中显示了"地址为0040A2C8的访问冲突"消息.读取地址00000001 '
有没有人知道Android上的方向传感器和磁场传感器之间的区别?
我的理解:
因为我读过磁力计是数字罗盘的代名词,我有点困惑.他们真的是什么?
我猜不,但你永远不会知道.
<img src="http://example.net/lolcat.png">lolcat.png到http://static.example.net/bandwidth-exceeded.gif我可以检测到这个吗?
跨浏览器并不重要,只需寻找可在任何1种流行浏览器中使用的选项.
到目前为止,我最好的选择是知道占位符图像的大小,通过查看图像大小onload(在支持图像标记中的onload事件的浏览器中)得到"可能",并发出快速XHR请求通知后端我们'我有一个可能.
我有两个问题:
1)是否可以实现使用alloca在堆栈上分配内存的分配器,否则符合C++ STL?
如果那里有代码,只需将我指向URL即可让我高兴.:-)如果那里没有代码,也许你可以草拟函数allocate和deallocate?
2)如果对上述问题的回答为"是",我想了解如何为类成员在堆栈上分配内存.举个例子,考虑一下
std::vector<int, AllocaAllocator<int> >
Run Code Online (Sandbox Code Playgroud)
并且假设对该向量的成员函数'resize'的调用首先调用'deallocate'然后'分配'分配器.
调用allocate的范围是成员函数resize的范围.这是不是意味着在该函数调用结束时从堆栈中删除了已分配的内存?
亲切的问候,Bjoern
我在这里看了一些关于使用ephem来计算日出和日落的例子,并且让它工作得很好.
当我试图计算这两次之间的中点时,我遇到了麻烦.这就是我所拥有的:
import datetime
import ephem
o = ephem.Observer()
o.lat, o.long, o.date = '37.0625', '-95.677068', datetime.datetime.utcnow()
sun = ephem.Sun(o)
print "sunrise:", o.previous_rising(sun), "UTC"
print "sunset:",o.next_setting(sun), "UTC"
print "noon:",datetime.timedelta((o.next_setting(sun)-o.previous_rising(sun))/2)
Run Code Online (Sandbox Code Playgroud)
我明白了:
日出:2010/11/2 12:47:40 UTC
日落:2010/11/2 23:24:25 UTC
中午:5:18:22.679044
那就是我被困住的地方.我是一个蟒蛇初学者,坦白说,一般来说,程序员并不多.
任何建议都是最受欢迎的!
我试图重写一些使用FileSearch for Excel 2003 VBA的代码.我试图调用一个应该确定1或0的函数,并使用一个If语句,我将执行一些代码或迭代到下一个文件.
我没有从我的函数返回正确的结果.
我的代码:
Dim MyDir As String, Fn As String
Dim MyFile As String
MyDir = "C:Test\"
Fn = "" & "" & Examiner & " " & MnName & " " & Yr & ".xls"
MyFile = MyDir & """" & Fn & """"
If FileThere(MyFile) Then
MsgBox yes
Else
MsgBox Not there
End If
'''''''''''''''''
Function FileThere(FileName As String) As Boolean
FileThere = (Dir(FileName) > "")
End Function
Run Code Online (Sandbox Code Playgroud) 所以我有这个index.php页面:
<?php
include main.php;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css" />
<title>MySite</title>
</head>
<body>
<a id = "submit" href="submit.php">Submit</a>
<br />
<br />
<br />
<br />
<br />
<p id = "playing">Message</p>
<?php
getMessage();
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
包含文件main.php如下所示:
<?php
function getMessage()
{
echo "Test";
}
?>
Run Code Online (Sandbox Code Playgroud)
但它并没有回应.为什么?
我想在函数中声明多个变量:
function foo() {
var src_arr = new Array();
var caption_arr = new Array();
var fav_arr = new Array();
var hidden_arr = new Array();
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
var src_arr = caption_arr = fav_arr = hidden_arr = new Array();
Run Code Online (Sandbox Code Playgroud) 我正试图subtitle在我的文本中显示一些文字tableView.
这是我的部分代码tableView:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } //did the subtitle style
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
cell.detailTextLabel.text = @"Hello there"; //This is not displaying...
}
}
Run Code Online (Sandbox Code Playgroud)
我跑的时候没有看到字幕文字的原因吗?
javascript ×2
alloca ×1
allocator ×1
android ×1
astronomy ×1
c++ ×1
components ×1
datetime ×1
declare ×1
delphi ×1
dom ×1
excel ×1
excel-vba ×1
html ×1
iphone ×1
magnetometer ×1
moq ×1
objective-c ×1
orientation ×1
php ×1
python ×1
stack ×1
stl ×1
uitableview ×1
variables ×1
vba ×1