我正在尝试运行MSTest.exe C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE.更重要的是,我将当前目录中的所有程序集都设置为单独的/ testcontainer参数.如果没有PowerShell的抱怨,我无法弄清楚如何做到这一点.
$CurrentDirectory = [IO.Directory]::GetCurrentDirectory()
$MSTestCall = '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"'
foreach($file in Get-ChildItem $CurrentDirectory)
{
if($file.name -match "\S+test\S?.dll$" )
{
$MSTestArguments += "/TestContainer:" + $file + " "
}
}
$MSTestArguments += " /resultsFile:out.trx"
$MSTestArguments += " /testsettings:C:\someDirectory\local64.testsettings"
Invoke-Expression "$MSTestCall $MSTestArguments"
Run Code Online (Sandbox Code Playgroud)
我从这段代码得到的错误是:
Invoke-Expression:您必须在'/'运算符的右侧提供值表达式.
当我尝试在名称中没有空格的目录中调用mstest.exe时,我不会收到此错误(不需要额外的").
当我尝试使用时&,
&$MSTestCall $MSTestArguments
Run Code Online (Sandbox Code Playgroud)
它将$ MSTestArguments作为单个参数交给MSTest提示抛出.建议?
我想要Write-Verbose一个out文件的很多数据.这就是我在做的方式.
Start-Transcript -Path $TargetDir\RunUnitTests.log -Width 1000000
Write-Verbose "five million character lines and stuff"
Run Code Online (Sandbox Code Playgroud)
这很好用,除了输出自动换行到控制台的标准宽度,这使得日志看起来非常糟糕.
我找到了一个解决方案,这里删除了死链接
,但它是如此复杂和复杂,我不想把它放在我的脚本下面的评论#Thar be dragons.
有一个更好的方法吗?
我在页面上有一个用户控件,需要在viewstate中保持某些状态.每当发生回发时,viewstate中的条目都将设置为null.
页
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" %>
<%@ Register TagPrefix="JR" TagName="JournalRanking" Src="~/Controls/JournalRankRadioButton.ascx" %>
<script runat="server">
</script>
<asp:Content ID="Content3" ContentPlaceHolderID="Content1placeholder" Runat="Server">
<asp:Panel CssClass="insetBG1" ID="FormView1" runat="server">
<JR:JournalRanking ID="JournalRanking1" runat="server" ViewStateMode="Inherit" />
</asp:Panel>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
用户控制
<%@ Control Language="C#" ClassName="JournalRankRadioButton" %>
<script runat="server">
public String Test
{
get
{
if (ViewState["Test"] == null)
{
ViewState["Test"] = String.Empty;
}
return ViewState["Test"].ToString();
}
set
{
ViewState["Test"] = value;
}
}
public void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.Test = "Test";
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个数据绑定到SqlDataSource的转发器
<asp:Repeater runat="server" ID="Repeater" DataSourceID="SqlDataSource">
<ItemTemplate>
<asp:HiddenField runat="server" Value='<%# Eval("Code") %>' ID="Code" />
<asp:TextBox ID="NumberNeeded" runat="server" Text='<%# Eval("Needed") %>' /><br />
</ItemTemplate>
</asp:Repeater>
<asp:Button runat="server" ID="submit" Text="submit" OnClick="submit_Click" />
<asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="rtvFiltered" SelectCommandType="StoredProcedure">
<SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
Run Code Online (Sandbox Code Playgroud)
我想迭代转发器并在submit_Click中获取NumberNeeded中的值
protected void submit_Click(object sender, EventArgs e)
{
this.Repeater.DataBind(); //comment this guy and this.Repeater.Items has no items
foreach (RepeaterItem item in this.Repeater.Items)
{
String code = ((HiddenField)item.FindControl("JournalCode")).Value;
// below fails because "NumberNeeded" control doesn't have the Text input by the …Run Code Online (Sandbox Code Playgroud) 我有一个powershell脚本,我想写一个控制台并通过一次调用写入日志文件.
我这样做......
Start-Transcript -Path $TargetDir\Log.log
Write-Host "Stuff"
Run Code Online (Sandbox Code Playgroud)
...效果很好,除了它生成的换行符是LF,这意味着我的日志在地球上的每个文本编辑器中看起来都很棒,除了记事本.
这就是我对此的看法......
function global:Write-Notepad
(
[string] $Message,
[string] $ForegroundColor = 'Gray'
)
{
Write-Host "$Message`r" -ForegroundColor $ForegroundColor
}
Run Code Online (Sandbox Code Playgroud)
...将CR写入每条消息的末尾,但它似乎没有写出这样的行......
&$ACommand | Write-Notepad
Run Code Online (Sandbox Code Playgroud)
我不确定管道操作员期望的语法,但我非常感谢帮助.
我有一个看起来像这样的课程
public class TestCase
{
public IEnumerable<string> Categories { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个TestCase对象列表,我希望能够按类别进行分组,这样如果一个TestCase在类别中具有值"a"和"b",那么该测试用例的实例将在分组中"a"和"b"的分组.我对Linq的GroupBy的理解让我相信它会使用IEnumerable的Equals方法,如果我按类别分组,我会为每个测试用例得到一个完全不同的组.
我有一个蛮力解决方案,实现了我想要的分组
var categoryGroups = new Dictionary<string, List<TestCase>>();
foreach (var testCase in testPackage.TestCase)
{
foreach (var category in testCase.Categories)
{
if (!categoryGroups.ContainsKey(category))
{
categoryGroups.Add(category, new List<TestCase>());
}
categoryGroups[category].Add(testCase);
}
}
Run Code Online (Sandbox Code Playgroud)
但这很难看.有没有更好的方法来获得我想要的分组?
我正在尝试用Java编写一个删除文件第一行的方法.
第一个想法(拒绝,因为调用.exec不是一个好习惯)
public void removeHeader(String fileName) throws IOException, InterruptedException {
if (StringUtils.isBlank(fileName)) {
throw new IllegalArgumentException("fileName was empty");
}
Process p = Runtime.getRuntime().exec("sed -i 1d " + fileName);
if (p.waitFor() != 0) {
throw new IOException("Failed to remove the header from " + fileName);
}
}
Run Code Online (Sandbox Code Playgroud)
第二个想法(在CR中被拒绝,因为迭代每一行并将其写入新文件是缓慢而不时尚的).
public void removeHeader(String fileName) throws IOException, InterruptedException {
if (StringUtils.isBlank(fileName)) {
throw new IllegalArgumentException("fileName was empty");
}
File inFile = new File(fileName);
File tempFile = new File(inFile.getAbsolutePath() + ".tmp");
BufferedReader br = null; …Run Code Online (Sandbox Code Playgroud)