我一直在考虑CI和自动构建很多,并且有兴趣知道是否有任何建立和维护持续集成环境的最佳实践.您是否使用项目源签入了所有CI相关文件?您通常如何构建CI和构建文件?欢迎任何提示!
我正在尝试为UrlHelper扩展方法编写一个测试,如下所示:
Url.Action<TestController>(x => x.TestAction());
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法正确设置它,以便我可以创建一个新的UrlHelper,然后断言返回的url是预期的url.这就是我所拥有的,但我对任何不涉及嘲弄的事情持开放态度.; O)
[Test]
public void Should_return_Test_slash_TestAction()
{
// Arrange
RouteTable.Routes.Add("TestRoute", new Route("{controller}/{action}", new MvcRouteHandler()));
var mocks = new MockRepository();
var context = mocks.FakeHttpContext(); // the extension from hanselman
var helper = new UrlHelper(new RequestContext(context, new RouteData()), RouteTable.Routes);
// Act
var result = helper.Action<TestController>(x => x.TestAction());
// Assert
Assert.That(result, Is.EqualTo("Test/TestAction"));
}
Run Code Online (Sandbox Code Playgroud)
我尝试将其更改为urlHelper.Action("Test","TestAction"),但无论如何都会失败,所以我知道这不是我的扩展方法无法正常工作.NUnit返回:
NUnit.Framework.AssertionException: Expected string length 15 but was 0. Strings differ at index 0.
Expected: "Test/TestAction"
But was: <string.Empty>
Run Code Online (Sandbox Code Playgroud)
我已经验证路由已注册并正在工作,我正在使用Hanselmans扩展来创建虚假的HttpContext.这是我的UrlHelper extentionmethod的样子:
public static string Action<TController>(this UrlHelper …Run Code Online (Sandbox Code Playgroud) 我需要帮助将以下SQL语句复制到SQLite理解的语句中.
SELECT * FROM SomeTable WHERE [Date] >= DATEADD(day, -14, GETDATE())
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢!
我们正在构建一个使用Owin托管的WebApi.以前我们已经使用HttpResponseException在我们的控制器操作中返回404状态代码等,并且它一直运行良好.
但是,当我们开始使用Owin(自托管)时,我们遇到了这种方法的问题,导致HttpResponseException被序列化为json/xml,状态代码从404更改为500(内部服务器错误).这是我们的代码:
public class InvoicesController : ApiController
{
private readonly IInvoiceRepository _invoiceRepository;
public InvoicesController(IInvoiceRepository invoiceRepository)
{
_invoiceRepository = invoiceRepository;
}
[HttpGet]
public IEnumerable<AccountCodeAssignment> AssignAccountCodesToInvoiceById(int id)
{
var invoice = _invoiceRepository.Get(id);
if (invoice == null) throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invoice not found"));
yield return new AccountCodeAssignment(1, ...);
yield return new AccountCodeAssignment(2, ...);
yield return new AccountCodeAssignment(3, ...);
yield return new AccountCodeAssignment(4, ...);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我们得到的响应以及500响应代码:
{
"Message": "An error has occurred.",
"ExceptionMessage": "Processing of the HTTP request resulted in an exception. Please …Run Code Online (Sandbox Code Playgroud) 我遇到了麻烦TryUpdateModel().我的表单字段以前缀命名,但我使用 - 作为我的分隔符而不是默认点.
<input type="text" id="Record-Title" name="Record-Title" />
Run Code Online (Sandbox Code Playgroud)
当我尝试更新模型时,它不会更新.如果我更改名称属性,Record.Title它可以完美地工作,但这不是我想要做的.
bool success = TryUpdateModel(record, "Record");
Run Code Online (Sandbox Code Playgroud)
是否可以使用自定义分隔符?
我正在寻找一种方法来加载Visual Studio(2010+)的解决方案/项目特定设置.
我知道有类似的问题,但我的要求有点不同.
以下是要求:
只是提供更多的上下文...我想更改Visual Studio的"保持选项卡","选项卡大小"和"缩进大小"设置.
我希望能够将一个名为"recent_date"的自定义函数作为我的HQL的一部分.像这样:[Date] >= recent_date()
我创建了一个新的方言,继承自MsSql2000Dialect并为我的配置指定了方言.
public class NordicMsSql2000Dialect : MsSql2000Dialect
{
public NordicMsSql2000Dialect()
{
RegisterFunction(
"recent_date",
new SQLFunctionTemplate(
NHibernateUtil.Date,
"dateadd(day, -15, getdate())"
)
);
}
}
var configuration = Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2000
.ConnectionString(c => .... )
.Cache(c => c.UseQueryCache().ProviderClass<HashtableCacheProvider>())
.Dialect<NordicMsSql2000Dialect>()
)
.Mappings(m => ....)
.BuildConfiguration();
Run Code Online (Sandbox Code Playgroud)
调用时recent_date()我得到以下错误:
System.Data.SqlClient.SqlException:'recent_date'不是可识别的函数名称
我正在使用where语句中的HasMany映射,如下所示.
HasMany(x => x.RecentValues)
.Access.CamelCaseField(Prefix.Underscore)
.Cascade.SaveUpdate()
.Where("Date >= recent_date()");
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
ASP.NET MVC 2中的继承属性和MetadataType似乎不适用于客户端验证.
我们的MetadataTypes验证在服务器上按预期工作,但由于某种原因,它不会为它生成适当的客户端脚本.对于在PersonView上设置了DataAnnotations属性的属性,客户端验证会按预期启动,因此我知道客户端验证是活动的并且它可以正常工作.有谁知道它是否或如何修复?
这是我们拥有的:
public abstract class PersonView
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
[Required] public string PhoneNumber { get; set; }
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string AddressZipCode { get; set; }
public string AddressCity { get; set; }
public string AddressCountry { get; set; }
}
[MetadataType(typeof(CustomerViewMetaData))]
public class CustomerView …Run Code Online (Sandbox Code Playgroud) 我从Cruise Control获得一个关于无法连接到服务器的例外.但是,如果我强制构建它可以正常工作.我也尝试使用repo-browser连接到服务器没有任何问题所以我知道服务器已启动并运行.我正在运行CCNET 1.4.4和SlikSVN 1.5.3.以下是CCNET日志的例外情况:
ThoughtWorks.CruiseControl.Core.CruiseControlException:
Source control operation failed: svn: OPTIONS of 'https://some-server.com/trunk': could not connect to server (https://some-server.com) .
Process command: C:\Program\SlikSvn\bin\svn.exe log https://some-server.com/trunk -r "{2009-06-23T01:36:19Z}:{2009-06-23T07:20:25Z}" --verbose --xml --username ccnet --password auto --non-interactive --no-auth-cache
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute(ProcessInfo processInfo)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Svn.GetModifications(IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.MultiSourceControl.GetModifications(IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.QuietPeriod.GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResult thisBuild)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.GetModifications(IIntegrationResult from, IIntegrationResult to) vid ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)
Run Code Online (Sandbox Code Playgroud)
任何想法将不胜感激!
asp.net-mvc ×3
automation ×1
c# ×1
hql ×1
nhibernate ×1
open-source ×1
owin ×1
rhino-mocks ×1
settings ×1
sqlite ×1
svn ×1
t-sql ×1
unit-testing ×1
urlhelper ×1
validation ×1