public ActionResult Index(ObjectModel model, string command) { // p = new PresenterModelVue(model); //Valide si il faut executer une commande if (command != null) { //Démarre le présenteur et demande de ne pas réinitialiser certaine valeur p.Start(false); //Appel à la fonction du processus de présentation en fonction de la commande, Le nom de la commande doit être identique à l'opération définit. model.ExecuteCommand(command); } else { p.Start(); } //Assigne le résultat du view logique qui contient l'ensemble des informations du résultat d'exécution du processus // Pour le passer au _layout.chtml qui détermine en fonction des résultats l'affichage des messages. ViewBag.ViewLogics = model.ViewLogics; //Execute les redirections si le processus de présentation à demandé une Navigation. if (model.ViewLogics.GoForm != null) { return(View(model.ViewLogics.GoForm.Item1, model.ViewLogics.GoForm.Item2["VIEW"])); } return(View(model)); }
public void ObjectModel_ExecuteCommandShould_ThrowAndLogExceptionWhenNullIsPassed() { // issue with test is that the log file cannot be deleted in teardown // due to static logger instance (is cleaned up after Main() exits) // research how to integration testing // Arrange var commandFactoryMock = new Mock <ICommandFactory <ObjectModel> >(); var objectUnderTest = new ObjectModel(commandFactoryMock.Object); AppioLogger.RegisterListener(new LoggerListenerWrapper()); // Act Assert.Throws <ArgumentNullException>(() => objectUnderTest.ExecuteCommand(null)); // Assert Assert.IsTrue(File.Exists(LogFileName)); }
public void ShouldGetInvalidInputParams() { // Arrange var factoryMock = new Mock <ICommandFactory <ObjectModel> >(); List <string> inputParams = null; var objectModel = new ObjectModel(factoryMock.Object); var errorWrittenOut = false; var loggerListener = new Mock <ILoggerListener>(); loggerListener.Setup(logger => logger.Error(LoggingText.NullInputParams_Msg, It.IsAny <ArgumentNullException>())).Callback(delegate { errorWrittenOut = true; }); AppioLogger.RegisterListener(loggerListener.Object); // Act Assert.Throws <ArgumentNullException>(() => objectModel.ExecuteCommand(inputParams)); // Assert Assert.IsTrue(errorWrittenOut); }
public void ShouldGetValidInputParams([ValueSource(nameof(ValidInputs))] string[] inputParams) { // Arrange var commandMock = new Mock <ICommand <ObjectModel> >(); var factoryMock = new Mock <ICommandFactory <ObjectModel> >(); var slnInputParams = inputParams.Skip(1); var objectModel = new ObjectModel(factoryMock.Object); factoryMock.Setup(factory => factory.GetCommand(inputParams.FirstOrDefault())).Returns(commandMock.Object); commandMock.Setup(s => s.Execute(slnInputParams)).Returns(new CommandResult(true, new MessageLines() { { "anyMsg", string.Empty } })); // Act var executionResult = objectModel.ExecuteCommand(inputParams); // Assert Assert.IsTrue(executionResult.Success); Assert.AreEqual("anyMsg", executionResult.OutputMessages.First().Key); }