public void QueueLog_Execute_ReturnsNotFoundMessage() { var command = new LogCommand(_console, LoggerMock.GetLogger <LogCommand>().Object, _projectService.Object, _jobQueueService.Object, _jobQueueLogListener.Object) { Project = "Project 1", Number = "2" }; var resultMessage = command.Execute(); Assert.Equal("Failed getting queue 2. Make sure the project name and queue number are correct.", resultMessage); }
public void QueueLog_Execute_JobQueuedReturnsSuccessMessage() { var command = new LogCommand(_console, LoggerMock.GetLogger <LogCommand>().Object, _projectService.Object, _jobQueueService.Object, _jobQueueLogListener.Object) { Project = "Project 1", Number = "1" }; var resultMessage = command.Execute(); Assert.StartsWith("Queue 1 is queued", resultMessage); }
public void QueueLog_Execute_JobProcessingReturnsSuccessMessage() { _jobQueueService.Setup(s => s.GetJobQueue(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new JobDto { Id = 1, ProjectId = 1, Status = JobStatus.Processing }); _jobQueueLogListener.Setup(s => s.Listen(1, 1, It.IsAny <Action <string> >(), It.IsAny <Action <string> >())).Returns(Task.CompletedTask); var command = new LogCommand(_console, LoggerMock.GetLogger <LogCommand>().Object, _projectService.Object, _jobQueueService.Object, _jobQueueLogListener.Object) { Project = "Project 1", Number = "1" }; command.Execute(); _jobQueueLogListener.Verify(s => s.Listen(It.IsAny <int>(), 1, It.IsAny <Action <string> >(), It.IsAny <Action <string> >()), Times.Once); }
public void QueueLog_Execute_JobCompletedReturnsSuccessMessage() { _jobQueueService.Setup(s => s.GetJobQueue(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new JobDto { Id = 1, ProjectId = 1, Status = JobStatus.Completed }); _jobQueueService.Setup(s => s.GetJobLogs(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync("test logs"); var command = new LogCommand(_console, LoggerMock.GetLogger <LogCommand>().Object, _projectService.Object, _jobQueueService.Object, _jobQueueLogListener.Object) { Project = "Project 1", Number = "1" }; var resultMessage = command.Execute(); Assert.Equal("test logs", resultMessage); }
/// <summary> /// Function that connect the server to clients. /// </summary> public void ConnectServer() { Thread.Sleep(100); IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8888); TcpListener listener = new TcpListener(ep); //first of all start the listener for searching connections. listener.Start(); Console.Write("Waiting for connection..."); HandleLogs handleLogs = new HandleLogs(); //thread for alwayes search for cnnections. Task ta = new Task(() => { while (true) { try { TcpClient client = listener.AcceptTcpClient(); //this.client = client; Console.WriteLine("Connection accepted."); m_logging.Log("Connection to server accepted", MessageTypeEnum.INFO); mutex3.WaitOne(); NetworkStream ns = client.GetStream(); byte[] bytes = new byte[1024]; //this.ns = client.GetStream(); int bytesRead = ns.Read(bytes, 0, bytes.Length); string r = Encoding.ASCII.GetString(bytes, 0, bytesRead); mutex3.ReleaseMutex(); Task task2 = new Task(() => { if (client.Connected) { if (r == "GetConfigCommand") { ICommand command = new GetConfigCommand(this, client, m_controller); bool success; command.Execute(null, out success); //HandleSettings h = new HandleSettings(this, client, m_controller); } else if (r == "LogCommand") { ICommand command = new LogCommand(handleLogs, this, m_logging, client); bool success; command.Execute(null, out success); //handleLogs.SetAllProt(this, m_logging , client); } } }); task2.Start(); /* * need to take care the close * when the client close the screen we should out this while ! * * */ } catch (Exception e) { break; } } }); ta.Start(); tcpListener = listener; }
public override void Run(string[] args) { cmd.Quiet = false; options = new CmdParserOptionSet() { { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() }, { "n=", "Limits the number of commits to show", v => cmd.n = v }, { "decorate=", "Print out the ref names of any commits that are shown", v => cmd.Decorate = v }, { "source", "Print out the ref name given on the command line by which each commit was reached", v => cmd.Source = true }, { "full-diff=", "Without this flag, \"git log -p <path>", v => cmd.FullDiff = v }, { "follow", "Continue listing the history of a file beyond renames", v => cmd.Follow = true }, { "log-size", "Before the log message print out its size in bytes", v => cmd.LogSize = true }, { "p|no-stat", "ifdef::git-format-patch[] Generate plain patches without any diffstats", v => cmd.NoStat = true }, { "P", "ifndef::git-format-patch[] Generate patch (see section on generating patches)", v => cmd.P = true }, { "u", "ifndef::git-format-patch[] Generate patch (see section on generating patches)", v => cmd.U = true }, { "U|unified=", "Generate diffs with <n> lines of context instead of the usual three", v => cmd.Unified = v }, { "raw", "ifndef::git-format-patch[] Generate the raw format", v => cmd.Raw = true }, { "patch-with-raw", "ifndef::git-format-patch[] Synonym for `-p --raw`", v => cmd.PatchWithRaw = true }, { "patience", "Generate a diff using the \"patience diff\" algorithm", v => cmd.Patience = true }, { "stat=", "Generate a diffstat", v => cmd.Stat = v }, { "numstat", "Similar to `--stat`, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly", v => cmd.Numstat = true }, { "shortstat", "Output only the last line of the `--stat` format containing total number of modified files, as well as number of added and deleted lines", v => cmd.Shortstat = true }, { "dirstat=", "Output the distribution of relative amount of changes (number of lines added or removed) for each sub-directory", v => cmd.Dirstat = v }, { "dirstat-by-file=", "Same as `--dirstat`, but counts changed files instead of lines", v => cmd.DirstatByFile = v }, { "summary", "Output a condensed summary of extended header information such as creations, renames and mode changes", v => cmd.Summary = true }, { "patch-with-stat", "ifndef::git-format-patch[] Synonym for `-p --stat`", v => cmd.PatchWithStat = true }, { "z", "ifdef::git-log[] Separate the commits with NULs instead of with new newlines", v => cmd.Z = true }, { "name-only", "Show only names of changed files", v => cmd.NameOnly = true }, { "name-status", "Show only names and status of changed files", v => cmd.NameStatus = true }, { "submodule=", "Chose the output format for submodule differences", v => cmd.Submodule = v }, { "color", "Show colored diff", v => cmd.Color = true }, { "no-color", "Turn off colored diff, even when the configuration file gives the default to color output", v => cmd.NoColor = true }, { "color-words=", "Show colored word diff, i", v => cmd.ColorWords = v }, { "no-renames", "Turn off rename detection, even when the configuration file gives the default to do so", v => cmd.NoRenames = true }, { "check", "ifndef::git-format-patch[] Warn if changes introduce trailing whitespace or an indent that uses a space before a tab", v => cmd.Check = true }, { "full-index", "Instead of the first handful of characters, show the full pre- and post-image blob object names on the \"index\" line when generating patch format output", v => cmd.FullIndex = true }, { "binary", "In addition to `--full-index`, output a binary diff that can be applied with `git-apply`", v => cmd.Binary = true }, { "abbrev=", "Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show only a partial prefix", v => cmd.Abbrev = v }, { "B", "Break complete rewrite changes into pairs of delete and create", v => cmd.B = true }, { "M", "Detect renames", v => cmd.M = true }, { "C", "Detect copies as well as renames", v => cmd.C = true }, { "diff-filter=", "ifndef::git-format-patch[] Select only files that are Added (`A`), Copied (`C`), Deleted (`D`), Modified (`M`), Renamed (`R`), have their type (i", v => cmd.DiffFilter = v }, { "find-copies-harder", "For performance reasons, by default, `-C` option finds copies only if the original file of the copy was modified in the same changeset", v => cmd.FindCopiesHarder = true }, { "l=", "The `-M` and `-C` options require O(n^2) processing time where n is the number of potential rename/copy targets", v => cmd.L = v }, { "S=", "ifndef::git-format-patch[] Look for differences that introduce or remove an instance of <string>", v => cmd.S = v }, { "pickaxe-all", "When `-S` finds a change, show all the changes in that changeset, not just the files that contain the change in <string>", v => cmd.PickaxeAll = true }, { "pickaxe-regex=", "Make the <string> not a plain string but an extended POSIX regex to match", v => cmd.PickaxeRegex = v }, { "O=", "Output the patch in the order specified in the <orderfile>, which has one shell glob pattern per line", v => cmd.O = v }, { "R", "ifndef::git-format-patch[] Swap two inputs; that is, show differences from index or on-disk file to tree contents", v => cmd.R = true }, { "relative=", "When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option", v => cmd.Relative = v }, { "a|text", "Treat all files as text", v => cmd.Text = true }, { "ignore-space-at-eol", "Ignore changes in whitespace at EOL", v => cmd.IgnoreSpaceAtEol = true }, { "b|ignore-space-change", "Ignore changes in amount of whitespace", v => cmd.IgnoreSpaceChange = true }, { "w|ignore-all-space", "Ignore whitespace when comparing lines", v => cmd.IgnoreAllSpace = true }, { "inter-hunk-context=", "Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other", v => cmd.InterHunkContext = v }, { "exit-code", "ifndef::git-format-patch[] Make the program exit with codes similar to diff(1)", v => cmd.ExitCode = true }, { "quiet", "Disable all output of the program", v => cmd.Quiet = true }, { "ext-diff", "Allow an external diff helper to be executed", v => cmd.ExtDiff = true }, { "no-ext-diff", "Disallow external diff drivers", v => cmd.NoExtDiff = true }, { "ignore-submodules", "Ignore changes to submodules in the diff generation", v => cmd.IgnoreSubmodules = true }, { "src-prefix=", "Show the given source prefix instead of \"a/\"", v => cmd.SrcPrefix = v }, { "dst-prefix=", "Show the given destination prefix instead of \"b/\"", v => cmd.DstPrefix = v }, { "no-prefix", "Do not show any source or destination prefix", v => cmd.NoPrefix = true }, }; try { List <String> arguments = ParseOptions(args); // log always uses a pager SetupPager(); cmd.Arguments = arguments .Select(path => Path.GetFullPath(path)) .ToList(); cmd.Execute(); } catch (System.IO.IOException) { // user closed pager } catch (Exception e) { Console.Error.WriteLine(e.ToString()); cmd.OutputStream.WriteLine(e.ToString()); } }