下载Nant 0.91后,我遇到了一些与配置或安全相关的相当神秘的配置错误(见下文).
我试图简单地将我的Nant可执行文件从0.86升级到0.91.
在Windows 7计算机上构建时,如何解决以下问题?
log4net:ERROR XmlConfiguratorAttribute:获取ConfigurationFileLocation的异常.必须能够在未设置ConfigFile和ConfigFileExtension属性时解析ConfigurationFileLocation.System.Security.SecurityException:请求类型为'System.Security.Permissions.FileIOPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败.在System.Security.CodeAccessSecurityEngine.Check在System.Security.CodeAccessSecurityEngine.Check(对象的需求,StackCrawlMark&stackMark,布尔isPermSet)(的CodeAccessPermission帽,StackCrawlMark&stackMark)在System.AppDomainSetup.VerifyDir在System.Security.CodeAccessPermission.Demand()( log dir,Boolean normalize)at log4net.Util.SystemInfo.get_ConfigurationFileLocation()at log4net.Config.XmlConfiguratorAttribute.ConfigureFromFile(Assembly sourceAssembly,ILoggerRepository targetRepository)
失败的操作是:Demand失败的第一个权限的类型是:System.Security.Permissions.FileIOPermission失败的程序集区域是:Internet
未处理的异常:System.Security.SecurityException:尝试访问配置节'nant'时,ConfigurationPermission请求失败.要允许所有调用者访问此部分的数据,请在声明此部分的配置文件中将section属性'requirePermission'设置为等于'false'.---> System.Security.SecurityException:请求类型'System.Configuration.ConfigurationPermission,System.Configuration,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的权限失败.在System.Security.CodeAccessSecurityEngine.Check在System.Security.CodeAccessSecurityEngine.Check(对象的需求,StackCrawlMark&stackMark,布尔isPermSet)(的CodeAccessPermission帽,StackCrawlMark&stackMark)在System.Configuration.BaseConfigurationRecord在System.Security.CodeAccessPermission.Demand(). CheckPermissionAllowed(String configKey,Boolean requirePermission,Boolean isTrustedWithoutAptca)---内部异常堆栈跟踪的结束---在System.Configuration.BaseConfigurationRecord.GetSectionRecursive的System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey,Boolean requirePermission,Boolean isTrustedWithoutAptca)处.串configKey,布尔getLkg,布尔的checkPermission,布尔getRuntimeObject,布尔requestIsHere,对象&结果,对象&resultRuntimeObject)在System.Configuration.BaseConfigurationRecord.GetSection(串configKey)在System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.位于NAnt.Console.ConsoleStub.Main(String [] args的NAnt.Console.ConsoleStub.Framework.GetRuntimeFramework()的System.Configuration.ConfigurationManager.GetSection(String sectionName)的GetSection(String sectionName)
(答案即将发布,张贴作为参考问题......)
这是我想做的事情:
我想创建一个包含我的资源文件的库项目(即UI标签和诸如此类的东西).我想在我的UI和测试中使用资源库.(即,我从多个项目中引用的资源基本上都有一个共同的位置.)
不幸的是,因为StronglyTypedResourceBuilder(生成资源代码的.Net类)默认使资源文件成为内部资源,所以我无法从另一个项目(即我的UI或测试)中引用库中的强类型资源,而不会跳转通过箍(即类似于此处描述的内容,或编写公共包装类/函数).
不幸的是,这两种解决方案都失去了我保持引用强类型的能力.
有没有人找到一种直接的方法来创建可以从多个项目中引用的强类型.Net资源?
我宁愿避免使用构建事件来实现这一目标(即,做一些事情,比如用'public'替换'internal'的所有实例,但如果我找不到,这基本上是我的后备计划一个答案..
有没有人找到一种方法来运行Selenium RC/Selenium Grid测试,用C#并行编写?
我目前使用Selenium RC的C#驱动程序编写了一个相当大的测试套件.运行整个测试套件需要一个多小时才能完成.我通常不需要运行整个套件,因此到目前为止它还没有引起关注,但我希望能够更频繁地进行操作(例如,作为自动构建的一部分)
我最近花了一些时间来讨论Selenium Grid项目,其目的主要是允许这些测试并行运行.不幸的是,似乎我正在使用的TestDriven.net插件连续运行测试(即,一个接一个).我假设NUnit会以类似的方式执行测试,虽然我实际上没有测试过.
我注意到NUnit 2.5测试版开始讨论与pNUnit并行运行测试,但我还没有真正熟悉这个项目,以确定这是否可行.
我正在考虑的另一个选择是将我的测试套件分成不同的库,这样我就可以同时从每个库中运行测试,但是我想尽可能避免这种情况,因为我不相信这是分裂的正当理由.测试套件.
我正在尝试使用NuGet包来配置Common.Logging以在ASP.Net MVC项目中使用NLog2.根据以下URL提供的信息,我相信我的记录器配置正确,但我仍然遇到配置错误.
我按照说明将以下内容添加到web.config中:
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="file" filename="e:\logfile.txt" layout="${date:format=yyyy/MM/dd HH:mm:ss} ${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile" />
</rules>
</nlog>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
据我所知,这是我应该做的一切,但是当我尝试运行Web项目时,我遇到了配置错误......
分析器错误消息:为common/logging创建配置节处理程序时出错:无法创建类型'Common.Logging.NLog.NLogLoggerFactoryAdapter,Common.Logging.NLog20'
任何人都可以提供有关缺失或错误的建议吗?
我正在尝试在发生意外错误时验证我的ASP.Net MVC应用程序的行为.具体来说,我正在尝试验证用户是否已定向到我为我的应用定义的错误页面.我遇到的问题是我无法按预期验证控制器方法的行为.
对于我的正常行为测试,我创建一个模拟业务规则对象并将其传递给我的控制器,然后从我想要测试的控制器方法验证ViewResult.当事情按预期工作时,这适用于我的目的.但是,当我从业务规则方法抛出异常时,异常通过控制器方法结果执行,而不是由控制器处理(控制器方法具有'HandleError'属性),以便为我的错误页面提供适当的ViewResult被退回.
有没有办法以这种方式验证HandleError属性的行为?或者我是否完全错了?我意识到我可以使用Selenium(在浏览器中进行实际服务器测试)来验证实际浏览器中的行为,但是模拟这些测试可以让我更快地完成这项工作并且开销更少......
样品测试代码:
// WidgetController.Index() makes a call to GetWidgets to retrieve a
// List<Widget> instance.
// this works as expected since the appropriate ViewResult is returned
// by the controller
public void TestWidgetControllerIndex_NoResultsFound()
{
var mockBR = new Mock<IBusinessRules> { CallBase = true };
mockBR.Setup(br=>fr.GetWidgets()).Returns(new List<Widget>());
WidgetController controller = new WidgetController(mockBR.Object);
ViewResult result = (ViewResult)controller.Index();
Assert.AreEqual("Index", result.ViewName);
Assert.AreEqual(0,
((WidgetIndexViewData)result.ViewData.Model).Widgets.Count);
}
// this test is unable to reach the assertion statements due to the …
Run Code Online (Sandbox Code Playgroud) 我正在设置Hudson作为集成服务器,我希望其他开发人员和堆栈持有者可以访问.我不想传递具有特定端口的URL,而是想配置Hudson来侦听端口80.
安装Hudson作为服务的默认端口是8080.我想在未运行IIS或Apache的Server 2008 R2或Windows 7计算机上将其更改为80.
我正在尝试对接口的实现进行单元测试,但在成功模拟接口方法之一的 SqlTransaction 参数时遇到了一些困难。
这是我感兴趣的接口和测试方法的样子。
public class MyInterface
{
void MyMethod(SqlTransaction SharedTransaction, DateTime EventTime);
}
public class MyImplementation : MyInterface
{
public void MyMethod(SqlTransaction SharedTransaction, DateTime EventTime)
{
DateTime dtLastEventTime = DateTime.MinValue;
using(SqlCommand comm = SharedTransaction.Connection.CreateCommand())
{
comm.CommandText = SQL_GET_LAST_EVENTTIME_DEFINED_ELSEWHERE;
comm.Parameters.AddWithValue("ParamName", 123);
object oResult = comm.ExecuteScalar();
dtLastEventTime = DateTime.Parse(oResult.ToString());
}
//Do something with dtLastEventTime
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在使用 Moq 和各种语法方法来模拟数据库对象,但运气不佳..(我必须对 System.Data.Common 对象进行一些转换,以便能够更进一步.. DbTransaction、DbConnection、DbCommand 等)。
我主要想知道的是是否可以通过这种方式模拟交易,或者我是否在这里找错了树。幸运的是,我也许能够将接口转换为使用通用的 DbTransaction 参数,而不是特定于提供程序的 SqlTransaction,但我不相信这就是我在模拟方面遇到困难的原因。
这是(这可能是完全错误的,所以如果我不正确地处理这个问题,请纠正我或发表评论)到目前为止我所得到的模拟代码......
var mockParams = new Mock<DbParameterCollection>();
mockParams.Setup(p => p.Add(new SqlParameter("ParamName", 123)));
var mockCommand = …
Run Code Online (Sandbox Code Playgroud) 我在Mercurial存储库中获得了代码(使用自签名证书保护),我正在尝试设置Jenkins以使用它.
我已经在Jenkins中安装了Mercurial插件(指向在Jenkins服务器/从服务器上安装TortoiseHg)并且Jenkins Job已正确配置为从存储库中获取源代码.
当我手动构建(即通过Web界面)时,一切都按预期工作.
但是,看起来存储库的轮询不成功,因为我得到类似于以下的输出:
Started on Apr 27, 2012 1:07:41 PM
[<jobname>] $ hg pull --rev default
warning: <MercurialServerIP> certificate with fingerprint e3:5f:5e:ea:4f:da:ef:a4:0b:4a:bb:00:e8:31:59:de:ce:d0:28:94 not verified (check hostfingerprints or web.cacerts config setting)
abort: mercurial_keyring: http authorization required but program used in non-interactive mode
[<jobname>] $ hg log --style <workspace>\<jobname>\tmp688470509422797505style --branch default --no-merges --prune 65d180b20a1e625841c8385709c86b83c3e10421
Done. Took 1.9 sec
No changes
Run Code Online (Sandbox Code Playgroud)
我之前已经完成了存储库的手动克隆,以便我能够输入用户的密码来使用Mercurial密钥环扩展来进行授权,但是根据错误输出,它似乎并没有被应用.
如何配置Jenkins或运行构建的计算机成功进行轮询?
我正在建立适当的CI环境,目前正在评估TeamCity.(所以我的TeamCity经验不存在.)
我在干净的Windows XP(现在)VM中执行了TeamCity 5.0.1 Professional的默认安装.
我创建了我的项目并将其指向我的源存储库并排队构建.
但是,我没有看到通过Team City Web界面安装/提供任何Build Agent.我已经检查过并且安装了"Team City Build Agent"服务并且它正在运行.我还查看了buildAgent文件夹中的日志文件,但没有看到任何会导致错误的内容.
是否有一个步骤或概念,我在这里缺少让默认的Build Agent可供Team City使用?我不打算做任何复杂的构建.(此时,我只是想从存储库中取出我的源代码)