-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3205 from icsharpcode/feature/atfile
`@file` support with breaking changes to command line options
- Loading branch information
Showing
15 changed files
with
292 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using System; | ||
|
||
using FluentAssertions; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace ICSharpCode.ILSpy.Tests | ||
{ | ||
[TestFixture] | ||
public class CommandLineArgumentsTests | ||
{ | ||
[Test] | ||
public void VerifyEmptyArgumentsArray() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { }); | ||
|
||
cmdLineArgs.AssembliesToLoad.Should().BeEmpty(); | ||
cmdLineArgs.SingleInstance.Should().BeNull(); | ||
cmdLineArgs.NavigateTo.Should().BeNull(); | ||
cmdLineArgs.Search.Should().BeNull(); | ||
cmdLineArgs.Language.Should().BeNull(); | ||
cmdLineArgs.NoActivate.Should().BeFalse(); | ||
cmdLineArgs.ConfigFile.Should().BeNull(); | ||
} | ||
|
||
[Test] | ||
public void VerifyHelpOption() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--help" }); | ||
cmdLineArgs.ArgumentsParser.IsShowingInformation.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void VerifyForceNewInstanceOption() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--newinstance" }); | ||
cmdLineArgs.SingleInstance.Should().BeFalse(); | ||
} | ||
|
||
[Test] | ||
public void VerifyNavigateToOption() | ||
{ | ||
const string navigateTo = "MyNamespace.MyClass"; | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateto", navigateTo }); | ||
cmdLineArgs.NavigateTo.Should().BeEquivalentTo(navigateTo); | ||
} | ||
|
||
[Test] | ||
public void VerifyNavigateToOption_NoneTest_Matching_VSAddin() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateto:none" }); | ||
cmdLineArgs.NavigateTo.Should().BeEquivalentTo("none"); | ||
} | ||
|
||
[Test] | ||
public void VerifyCaseSensitivityOfOptionsDoesntThrow() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--navigateTo:none" }); | ||
|
||
cmdLineArgs.ArgumentsParser.RemainingArguments.Should().HaveCount(1); | ||
} | ||
|
||
[Test] | ||
public void VerifySearchOption() | ||
{ | ||
const string searchWord = "TestContainers"; | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--search", searchWord }); | ||
cmdLineArgs.Search.Should().BeEquivalentTo(searchWord); | ||
} | ||
|
||
[Test] | ||
public void VerifyLanguageOption() | ||
{ | ||
const string language = "csharp"; | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--language", language }); | ||
cmdLineArgs.Language.Should().BeEquivalentTo(language); | ||
} | ||
|
||
[Test] | ||
public void VerifyConfigOption() | ||
{ | ||
const string configFile = "myilspyoptions.xml"; | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--config", configFile }); | ||
cmdLineArgs.ConfigFile.Should().BeEquivalentTo(configFile); | ||
} | ||
|
||
[Test] | ||
public void VerifyNoActivateOption() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "--noactivate" }); | ||
cmdLineArgs.NoActivate.Should().BeTrue(); | ||
} | ||
|
||
[Test] | ||
public void MultipleAssembliesAsArguments() | ||
{ | ||
var cmdLineArgs = new CommandLineArguments(new string[] { "assembly1", "assembly2", "assembly3" }); | ||
cmdLineArgs.AssembliesToLoad.Should().HaveCount(3); | ||
} | ||
|
||
[Test] | ||
public void PassAtFileArguments() | ||
{ | ||
string filepath = System.IO.Path.GetTempFileName(); | ||
|
||
System.IO.File.WriteAllText(filepath, "assembly1\r\nassembly2\r\nassembly3\r\n--newinstance\r\n--noactivate"); | ||
|
||
var cmdLineArgs = new CommandLineArguments(new string[] { $"@{filepath}" }); | ||
|
||
try | ||
{ | ||
System.IO.File.Delete(filepath); | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
|
||
cmdLineArgs.SingleInstance.Should().BeFalse(); | ||
cmdLineArgs.NoActivate.Should().BeTrue(); | ||
cmdLineArgs.AssembliesToLoad.Should().HaveCount(3); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.