Do not move forward if there is parsing error

This commit is contained in:
William Li 2017-09-10 11:47:19 -07:00
parent 6fdc98c23b
commit 9c1fa7c9d9
3 changed files with 52 additions and 3 deletions

View file

@ -7,6 +7,7 @@ using Microsoft.DotNet.Cli.Telemetry;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Test.Utilities;
using System.Collections.Generic;
using System;
using Xunit;
namespace Microsoft.DotNet.Tests
@ -24,6 +25,22 @@ namespace Microsoft.DotNet.Tests
TelemetryEventEntry.TelemetryFilter = new TelemetryFilter();
}
[Fact]
public void NoTelemetryIfCommandIsInvalid()
{
string[] args = { "publish", "-r"};
Action a = () => { Cli.Program.ProcessArgs(args); };
a.ShouldNotThrow<ArgumentOutOfRangeException>();
}
[Fact]
public void NoTelemetryIfCommandIsInvalid2()
{
string[] args = { "restore", "-v" };
Action a = () => { Cli.Program.ProcessArgs(args); };
a.ShouldNotThrow<ArgumentOutOfRangeException>();
}
[Fact]
public void TopLevelCommandNameShouldBeSentToTelemetry()
{
@ -120,7 +137,7 @@ namespace Microsoft.DotNet.Tests
public void DotnetNugetCommandFirstArgumentShouldBeSentToTelemetry()
{
const string argumentToSend = "push";
string[] args = {"nuget", argumentToSend, "aRoot"};
string[] args = {"nuget", argumentToSend};
Cli.Program.ProcessArgs(args);
_fakeTelemetry
.LogEntries.Should()