public void TestSavingReview() { // Create a review process model with a test value. ReviewProcessViewModel model = new ReviewProcessViewModel() { SelectedFoodItemId = 0, TestId = 0, FoodParcelId = 0, AromaValue = 3 }; // Create a test repository. TestResultItemTestRepository resultItemTestRepository = new TestResultItemTestRepository(); // Create a worker to process the request. Note only the repository I need is passed. ReviewWorker reviewWorker = new ReviewWorker(null, null, null, resultItemTestRepository, null); // Save the review. reviewWorker.SaveReview(model, "Test User"); // Get the saved item. TestResultItem result = resultItemTestRepository.Get(0); // Check the value has been saved. Assert.True(result.Result == model.AromaValue, "The new aroma value was not saved."); }
// Last changes: // 1. "Pr": optional key "--onlyPr" added static async Task Main(string[] args) { var onlyOne = args.Any(); var settings = ReadSettings(); var jira = Jira.CreateRestClient( "https://jira.devfactory.com", settings.CommonSettings.JiraUserName, settings.CommonSettings.JiraPassword); var parameters = args; while (true) { if (!onlyOne) { Console.Write("Enter command: "); parameters = (Console.ReadLine() ?? string.Empty).Split(' ', StringSplitOptions.RemoveEmptyEntries); if (!parameters.Any()) { continue; } } var command = parameters[0]; var commandParameters = new Parameters(parameters.Skip(1).ToArray()); try { switch (command.ToLower()) { case "fp": await FalsePositiveWorker.DoWork(settings.FpCommand, commandParameters, jira); break; case "new": await NewWorker.DoWork(settings.NewCommand, settings.CommonSettings, commandParameters, jira); break; case "pr": await MakePrWorker.DoWork(settings.PrCommand, settings.CommonSettings, commandParameters, jira); break; case "crn": await CrnWorker.DoWork(settings.CrnCommand, settings.CommonSettings, commandParameters, jira); break; case "ci": await CiWorker.DoWork(settings.CrnCommand, settings.CommonSettings, commandParameters, jira); break; case "review": await ReviewWorker.DoWork(settings.ReviewCommand, settings.CommonSettings, commandParameters, jira); break; case "rebase": await RebaseWorker.DoWork(settings.RebaseCommand, settings.CommonSettings, commandParameters, jira); break; case "solve": await SolveWorker.DoWork(settings.CommonSettings, commandParameters, jira); break; case "exit": return; default: Console.WriteLine($"Unknown command: {command}"); break; } } catch (CcException ex) { if (Console.CursorLeft > 0) { Console.WriteLine(); } ConsoleHelper.WriteLineColor(ex.Message, ConsoleColor.Red); } catch (GitException ex) { Console.WriteLine(); Console.Write("Git process exited with error code"); Console.WriteLine(); foreach (var line in ex.Output) { Console.WriteLine(line); } foreach (var line in ex.Error) { ConsoleHelper.WriteLineColor(line, ConsoleColor.Red); } } catch (Exception e) { Console.WriteLine(); Console.WriteLine(e); File.AppendAllText(AppFolderHelper.GetFile("log.txt"), $"[{DateTime.Now}] {e}\r\n"); } if (onlyOne) { break; } Console.WriteLine("================================"); } }