是否可以在Windows 7(或者甚至是XP)中从命令提示符处在系统级别设置环境变量.我从一个提升的命令提示符运行.
当我使用set
command(set name=value
)时,环境变量似乎仅对命令提示符的会话有效.
我有一个PowerShell脚本D:\temp
.
当我运行此脚本时,我希望列出该文件的当前位置.我该怎么做呢?
例如,此代码将在DOS批处理文件中完成; 我想将其转换为PowerShell脚本...
FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa
CD /d "%this_cmds_dir%"
Run Code Online (Sandbox Code Playgroud) 的冯·诺依曼体系结构描述了指令和数据被存储在存储器中所存储的程序的计算机和机的工作原理,通过改变其内部状态,即,一个指令在某些数据进行操作,并修改数据.因此,系统中存在状态.
的图灵机体系结构的工作原理是在磁带上操纵符号.即存在具有无限数量的槽的带,并且在任何一个时间点,图灵机都在特定的槽中.根据在该插槽读取的符号,机器可以更改符号并移动到不同的插槽.所有这些都是确定性的.
这两个模型之间有什么关系吗?冯·诺伊曼模型是基于图灵模型还是受其启发?
我们可以说图灵模型是Von Newman模型的超集吗?
功能编程是否适合图灵模型?如果是这样,怎么样?我认为功能编程并不适合Von Neuman模型.
computer-science cpu-architecture turing-machines von-neumann
使用Rhino Mocks,如何确保在模拟对象上设置Expectations时不调用方法.
在我的示例中,我正在测试Commit方法,我需要确保在执行提交时不调用Rollback方法.(这是因为我在提交方法中有逻辑,如果提交失败将自动回滚)
这是代码的样子......
[Test]
public void TestCommit_DoesNotRollback()
{
//Arrange
var mockStore = MockRepository.GenerateMock<IStore>();
mockStore.Expect(x => x.Commit());
//here i want to set an expectation that x.Rollback() should not be called.
//Act
subject.Commit();
//Assert
mockStore.VerifyAllExpectation();
}
Run Code Online (Sandbox Code Playgroud)
当然,我可以在Assert阶段这样做:
mockStore.AssertWasNotCalled(x => x.Rollback());
Run Code Online (Sandbox Code Playgroud)
但我想首先将此作为期望.
使用RhinoMocks,我试图Stub一个属性的getter值.该属性被定义为仅具有getter访问权限的接口的一部分.
但是我收到错误"无效的呼叫,已使用最后一次呼叫或未进行任何呼叫(确保您正在调用虚拟(C#)/可覆盖(VB)方法)." 我明白这可能意味着我存在的财产不是虚拟的; 但它是接口的一部分,我不确定这是否是我收到此错误的原因..
下面是代码框架.如果我取消注释"stubRepository.Stub(x => x.StoreDeviceID).PropertyBehavior();"的行,那么我得到一个新错误"属性必须是读/写".我搜索了SO并找到了这个页面.但建议的解决方案对我没有帮助.有什么想法吗?
public interface IStore {
string StoreDeviceID {get;}
//other methods
}
public static class Store {
private IStore Repository;
public void SetRepository(IStore rep){
Repository = rep;
}
public StoredeviceID {
get{
return Repository.StoreDeviceID;
}
}
//other methods
}
public class TestClass {
[Test]
public void TestDeviceID() {
var stubRepository =
MockRepository.GenerateStub<IStore>();
Store.SetRepository(stubRepository);
//stubRepository.Stub(x => x.StoreDeviceID).PropertyBehavior();
SetupResult.For(stubRepository.StoreDeviceID).Return("test");
Assert.AreSame(Store.StoreDeviceID, "test");
}
}
Run Code Online (Sandbox Code Playgroud) 我使用Rhino Mocks作为单元测试的模拟框架.
我有一个名为Subject的类,它是我想要测试的类.它依赖于IStore.
IStore定义如下:
//internal interface : has InternalsVisible to both "Subject"
//and "StoreTests" class namespaces
internal interface IStore {
void Store(string name);
//other methods
}
Run Code Online (Sandbox Code Playgroud)
Subject类定义如下:
class Subject : IStore {
private IStore internalStore;
//constructor injection
void Subject(IStore store) {
internalStore = store;
}
void Store(string name) {
internalStore.Store(name);
}
//other methods
}
Run Code Online (Sandbox Code Playgroud)
我使用RhinoMocks的测试类如下:
//test class
class StoreTests {
Subject subject = new Subject();
[Test]
public StoreTest() {
//Arrange
var mockStore = MockRepository.GenerateMock<IStore>();
string testName = "test";
mockStore.Expect(x => …
Run Code Online (Sandbox Code Playgroud) .NET中是否有任何库允许我在Windows 7中操作具有高级安全性的Windows防火墙?
我问这个的原因是因为,我希望能够以编程方式添加程序/端口异常.
例如,我想将program.exe添加到入站规则部分,对于此程序,我想允许TCP端口5660和UDP端口5660.应该仅为此程序阻止所有其他端口;
我推断这可以在具有高级安全性的Windows防火墙的入站规则部分中轻松设置; 我希望这是最好的方式吗?
但是,我将如何以编程方式完成该操作?
我已经在这里看到了一个例子,但我认为这个问题谈到了"允许程序通过Windows防火墙管理单元",它没有端口信息.
你能不能帮我解决这个难题,我无法找到一个好的答案!
有49辆车以独特的速度比赛.还有一条赛道,最多可以有7辆车一起比赛.我们需要找到该组中第25快的汽车.我们没有秒表来衡量时间(所以我们只能测量每辆车在比赛中其他6辆车的相对速度).什么是最少的比赛需要?
如何在VBScript中检测Windows操作系统的位数(32位与64位)?
我试过这种方法,但它不起作用; 我猜(x86)导致检查文件夹的一些问题..
还有其他选择吗?
progFiles="c:\program files" & "(" & "x86" & ")"
set fileSys=CreateObject("Scripting.FileSystemObject")
If fileSys.FolderExists(progFiles) Then
WScript.Echo "Folder Exists"
End If
Run Code Online (Sandbox Code Playgroud) 使用Perl,如何确定我的程序是在32位Windows还是64位Windows上运行?
有没有可用的API?
我可以想到几个选择..
检查一些Windows文件的PE_HEADER(例如:) c:\windows\explorer.exe
- 也许我可以使用详细信息如何测试windows dll以确定它是32位还是64位?
检查是否存在c:\program files(x86)
- 如果存在则则为64位操作系统.否则它是一个32位Windows操作系统.
这样做有什么好办法吗?Perl中可用的任何API?
c# ×4
rhino-mocks ×3
windows ×3
batch-file ×2
unit-testing ×2
32bit-64bit ×1
64-bit ×1
algorithm ×1
cmd ×1
firewall ×1
internal ×1
perl ×1
powershell ×1
properties ×1
puzzle ×1
stub ×1
vbscript ×1
von-neumann ×1
windows-7 ×1