小编the*_*ric的帖子

如何在Teamcity上使用ApprovalTests?

我正在使用审批测试.在我的开发机器上DiffReporter,当我的测试结果与批准的不同时,我很高兴开始使用TortoiseDiff:

    [UseReporter(typeof (DiffReporter))]
    public class MyApprovalTests
    { ... }
Run Code Online (Sandbox Code Playgroud)

但是,当在Teamcity上运行相同的测试并且结果不同时,测试将失败,并显示以下错误:

System.Exception : Unable to launch: tortoisemerge.exe with arguments ...
Error Message: The system cannot find the file specified
---- System.ComponentModel.Win32Exception : The system cannot find the file 
                                                                 specified
Run Code Online (Sandbox Code Playgroud)

显然它找不到tortoisemerge.exe,这很好,因为它没有安装在构建代理上.但是如果它被安装了怎么办?然后对于每个失败,另一个tortoisemerge.exe实例将启动,没有人会关闭它.最终吨的tortoisemerge.exe实例将杀死我们的服务器:)

所以问题是 - 如何修改测试以在本地机器上运行Tortoise Diff并仅在构建服务器上报告错误?我知道 #IF DEBUG [UseReporter(typeof (DiffReporter))]但如果可能的话会更喜欢另一种解决方案.

.net c# teamcity continuous-integration approval-tests

12
推荐指数
1
解决办法
1814
查看次数

如何从XML获取所有叶元素的xpath?

我想知道是否可以创建一个XSLT样式表,它将为给定XML文件中的所有叶元素提取XPATH.例如

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <item1>value1</item1>
    <subitem>
        <item2>value2</item2>
    </subitem>
</root>
Run Code Online (Sandbox Code Playgroud)

输出将是

/root/item1
/root/subitem/item2
Run Code Online (Sandbox Code Playgroud)

xml xslt xpath

11
推荐指数
2
解决办法
7869
查看次数

从VS Code终端登录AzureRmAccount

当我尝试从VS Code终端登录Azure RM时,它就会挂起.没有显示登录/密码的提示.

有没有办法从该终端登录?否则运行/调试Azure PS脚本变得比它应该更复杂:)

azure azure-powershell visual-studio-code

10
推荐指数
1
解决办法
1655
查看次数

如何将POCO类传递给.NET Core配置

我正在进行.NET Core应用程序的集成测试,并希望使用一些测试配置.我的配置是一个POCO类,通过appsettings.json然后通过消耗配置IOptions<T>.在我的测试中,我想使用该类的实例.

这是代码:

 var mySettings = GetTestSettings(); // factory method returning POCO class 
 var configurationBuilder = new ConfigurationBuilder();

 // I am looking for something like 
 configurationBuilder.AddInMemoryObject("Settings", mySettings);

 // does not work, result is just string 
 configurationBuilder.AddInMemoryCollection("Settings",
        JsonConvert.SerializeObject(mySettings)); 

// requires filename
configurationBuilder.AddJsonFile("filename.json");
Run Code Online (Sandbox Code Playgroud)

将POCO提供给配置的最简单方法是什么?

.net-core asp.net-core

10
推荐指数
2
解决办法
772
查看次数

为什么在SqlConnection.Open()中可能发生超时?

在SqlConnection.Open()中发生超时的情况是什么?

在AppProcess回收10秒后,在我们的一个IIS框中出现以下异常:

Type : System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    Source : .Net SqlClient Data Provider
    Help link : 
    Errors : System.Data.SqlClient.SqlErrorCollection
    Class : 11
    LineNumber : 0
    Number : -2
    Procedure : 
    Server : XXX
    State : 0
    ErrorCode : -2146232060
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void OnError(System.Data.SqlClient.SqlException, Boolean)
    Stack Trace :    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) …
Run Code Online (Sandbox Code Playgroud)

sql-server nhibernate ado.net timeout

7
推荐指数
1
解决办法
3万
查看次数

如何在Approvaltests中添加对xunit的Theory属性的支持

当我尝试使用带有[Theory]属性的单元测试批准时,它说:

System.Exception: System.Exception : Approvals is not set up to use your test framework.
It currently supports [NUnit, MsTest, MbUnit, xUnit.net]
To add one use ApprovalTests.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.StackTraceParsers.IStackTraceParser with support for your testing framework.
To learn how to implement one see http://blog.approvaltests.com/2012/01/creating-namers.html
   at ApprovalTests.StackTraceParsers.StackTraceParser.Parse(StackTrace stackTrace)
   at ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
   at ApprovalTests.Approvals.GetDefaultNamer()
   at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
   at ApprovalTests.Approvals.Verify(Object text)
Run Code Online (Sandbox Code Playgroud)

似乎它只识别[Fact]属性.我试图关注stacktrace中链接, 但没有关于如何将自己的名称/解析器插入批准的内容.

有没有我可以添加自己的名字/解析器的入口点?它本身似乎微不足道,唯一的问题是如何使用它:

 public class TheoryNamer : AttributeStackTraceParser
    {
        protected override string GetAttributeType()
        { …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing xunit.net approval-tests

6
推荐指数
1
解决办法
2290
查看次数

如何在(流畅的)NHibernate中使用字符串键

我正在使用使用字符串作为主键的brownfield数据库.使用Fluent NHibernateSqlite(内存提供程序进行单元测试)和SQL Server 2005.

我有以下实体:

public class Entity
{
    public virtual DateTime TimeStamp { get; set; }

    public virtual string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

有了这个映射:

public class EntityMap : ClassMap<Entity>
{
    public EntityMap()
    {
        Map(_ => _.TimeStamp);
        Id(_ => _.Name).CustomType("AnsiString");
    }
}
Run Code Online (Sandbox Code Playgroud)

然而它说不起作用 NHibernate.TypeMismatchException : Provided id of the wrong type. Expected: System.Int32, got System.String

如何使这项工作?另外,有没有关于流利的nhibernate可用的良好文档?

提前致谢.

.net c# database nhibernate fluent-nhibernate

5
推荐指数
1
解决办法
3342
查看次数

如何从构建日志中删除批准的调试信息

当我运行批准测试时,批准测试的一些调试输出会进入我的日志.看起来像 2/15/2016 1:58:48 PM ~000002ms Variable: approvalFrame = '' 2/15/2016 1:58:48 PM ~000025ms Variable: approvalFrame = '' 2/15/2016 1:58:48 PM ~000003ms Variable: approvalFrame = '' 2/15/2016 1:58:48 PM ~000002ms Variable: approvalFrame = '......

有没有办法将其隐藏在日志中?

谢谢.

.net unit-testing approval-tests

5
推荐指数
1
解决办法
61
查看次数

通过单个命令通过Nuget安装多个软件包

我通过Visual Studio的软件包管理器控制台使用Nuget.对于每个项目,我需要添加一些软件包,例如xunit.contribs,fluentassertions和nsubstitute.为此,我在consolle中键入3个命令.

我知道控制台只是另一个PowerShell主机,应该有一种方法来创建一个脚本(一种Add-Test-Stuff.ps1),它将一次添加几个包.最好的方法是什么?

powershell visual-studio-2010 nuget

4
推荐指数
1
解决办法
4141
查看次数

Xmldoc.load 给出的对象引用未设置为对象的实例

我有一个包含 XML 的字符串。我想从中创建一个 XML 文档。我正在使用 Load 和 LoadXMl 方法,如下所示:

   Dim doc As XmlDocument
            doc.LoadXml(applicationXml)
Run Code Online (Sandbox Code Playgroud)

但他们正在重新调整:

Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)

我的 XML 看起来像这样:

<gate.util.persistence.GateApplication>
  <urlList class="gate.util.persistence.CollectionPersistence">
    <localList>      
      <gate.util.persistence.PersistenceManager-URLHolder>
        <urlString>$gatehome$plugins/LingPipe/</urlString>
      </gate.util.persistence.PersistenceManager-URLHolder>
      <gate.util.persistence.PersistenceManager-URLHolder>
        <urlString>$gatehome$plugins/ANNIE/</urlString>
      </gate.util.persistence.PersistenceManager-URLHolder>
      <gate.util.persistence.PersistenceManager-URLHolder>
        <urlString>$gatehome$plugins/Stemmer_Snowball/</urlString>
      </gate.util.persistence.PersistenceManager-URLHolder>     
    </localList>
    <collectionType>java.util.ArrayList</collectionType>
  </urlList>
  <application class="gate.util.persistence.SerialAnalyserControllerPersistence">
    <prList class="gate.util.persistence.CollectionPersistence">
      <localList>
        <gate.util.persistence.PRPersistence>
          <runtimeParams class="gate.util.persistence.MapPersistence">
            <mapType>gate.util.SimpleFeatureMapImpl</mapType>
            <localMap>
              <entry>
                <string>setsToKeep</string>
                <null />
              </entry>
              <entry>
                <string>document</string>
                <null/>
              </entry>
              <entry>
                <string>annotationTypes</string>
                <null/>
              </entry>
              <entry>
                <string>corpus</string>
                <null/>
              </entry>
              <entry>
                <string>keepOriginalMarkupsAS</string>
                <boolean>true</boolean>
              </entry>
              <entry>
                <string>setsToRemove</string>
                <null/>
              </entry>
            </localMap> …
Run Code Online (Sandbox Code Playgroud)

xml vb.net

2
推荐指数
1
解决办法
1044
查看次数