我运行一个C#单元测试(VS 2008)。内测试我写入设置,这将导致在将数据保存到所述user.config
I am running a c# unit test (VS 2008). Within the test I do write to the settings, which should result in saving the data to the user.config.
Settings.Default.X = "History"; // X is string
Settings.Default.Save();
但是这根本无法创建文件(我已经在交叉检查C: Documents和Settings 硬件本地设置应用数据)。
But this simply does not create the file (I have crosschecked under "C:Documents and SettingsHWLocal SettingsApplication Data").
如果我创建相同的东西,作为一个控制台应用程序,是没有问题的持久化数据(同code)。
If I create the same stuff as a Console application, there is no problem persisting the data (same code).
有没有我需要考虑的一个的UnitTest这样做一些特别的东西?
Is there something special I need to consider doing this in a UnitTest?
推荐答案
我尝试了与Visual Studio 2010的Windows 7和Visual Studio的单元测试框架实际上是创造了测试应用中,我发现我的用户临时文件夹。配置文件与正确的设置。我想可能是在VS 2008中同样的事情。 这些文件夹的路径方案是什么样的:
I tried it with Visual Studio 2010 on Windows 7 and the Visual Studio Unit Test framework is actually creating a temporary folder for test applications in which I found my user.config file with correct settings. I think it might be the same thing on VS 2008. The path scheme to these folder is of the kind:
的Windows Vista /七路径:
Windows Vista/Seven path:
C:用户 $ USER $ 应用程序数据本地 Microsoft_Corporation TestAppDomain {NUMBER}
C:Users$USER$AppDataLocalMicrosoft_CorporationTestAppDomain{Number}
Windows XP的路径:
Windows XP path:
C: Documents和Settings $ USER $ 本地设置 Microsoft_Corporation TestAppDomain {NUMBER}
C:Documents and Settings$USER$Local SettingsMicrosoft_CorporationTestAppDomain{Number}
祝你好运。
相关推荐
最新文章