#pragma warning restore 0649 // Main entry point. Simply set up a httpClient to access the CI // and switch on the command to invoke underlying logic. private static int Main(string[] args) { Config config = new Config(args); int error = 0; CIClient cic = new CIClient(config); Command currentCommand = config.DoCommand; switch (currentCommand) { case Command.List: { ListCommand.List(cic, config).Wait(); break; } case Command.Copy: { CopyCommand.Copy(cic, config).Wait(); break; } default: { Console.Error.WriteLine("super bad! why no command!"); error = 1; break; } } return(error); }
public void List_ListsReferences() { var currentDir = Directory.GetCurrentDirectory(); var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); try { // Arrange var testConsole = new TestConsole(); new DirectoryInfo(Path.Combine(currentDir, "TestAssets", "MultipleReferences")).CopyTo(tempDir); // Act Directory.SetCurrentDirectory(tempDir); var command = new ListCommand(testConsole, null, CreateClient()); Assert.IsNotNull(command.Project); Assert.AreEqual("test.csproj", Path.GetFileName(command.Project.FullPath)); command.List(); // Assert var output = testConsole.Out.ToString() !; var lines = output.Split(Environment.NewLine); // First line is the heading and should conatin Protobuf Reference, Service Type, Source URL, Access AssertContains(lines[0], "Protobuf Reference"); AssertContains(lines[0], "Service Type"); AssertContains(lines[0], "Source URL"); AssertContains(lines[0], "Access"); // Second line is the reference to //<Protobuf Include="Proto/a.proto"> // <SourceUrl>https://contoso.com/greet.proto</SourceUrl> //</Protobuf> Assert.AreEqual(new string[] { "Proto/a.proto", "Both", "https://contoso.com/greet.proto" }, lines[1].Split(' ', StringSplitOptions.RemoveEmptyEntries)); // Third line is the reference to //<Protobuf Include="Proto/b.proto" Access="Internal"/> Assert.AreEqual(new string[] { "Proto/b.proto", "Both", "Internal" }, lines[2].Split(' ', StringSplitOptions.RemoveEmptyEntries)); } finally { // Cleanup Directory.SetCurrentDirectory(currentDir); Directory.Delete(tempDir, true); } }