public void ExecuteNonExistentCommand() { ExecuteDotnetTask task = Context.CoreTasks().ExecuteDotnetTask("nonexist") .Executable(PathToDotnetExecutable); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); }
public void MissingUpdates() { UpdateJsonFileTask task = new UpdateJsonFileTask("TestData/testproject.json".ExpandToExecutingPath()); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); Assert.StartsWith("Nothing to update in file", e.Message); Assert.Equal(2, e.ErrorCode); }
public void MissingFile() { UpdateJsonFileTask task = new UpdateJsonFileTask("nonext.json"); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); Assert.Equal("JSON file nonext.json not found!", e.Message); Assert.Equal(1, e.ErrorCode); }
public void ToolsVersionWasNotFoundAndThereIsNoNewerOne() { SetupMsBuildVersions(include40: false, include120: false); _task = new CompileSolutionTask("x.sln", "Release", _flubuEnviroment.Object); _task.SetToolsVersion(new Version("4.0")); TaskExecutionException ex = Assert.Throws <TaskExecutionException>(() => _task.ExecuteVoid(Context.Object)); Assert.Equal("Requested MSBuild tools version 4.0 not found and there are no higher versions", ex.Message); }
public void ExecuteWrongArgsCommand() { ExecuteDotnetTask task = new ExecuteDotnetTask("build") .Executable(PathToDotnetExecutable) .WithArguments("Flubu.NonExtstProj"); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.Execute(Context)); Assert.Equal(1, e.ErrorCode); }
public void OnStepFailed(TaskExecutionException exception, ITaskStep step, TaskDefinition task) { _stepFailed?.Invoke(new StepFailedEvent { Exception = exception, Step = step, Task = task, Timestamp = DateTimeUtils.Now }); }
public void FailOnUpdateNotFound() { UpdateJsonFileTask task = new UpdateJsonFileTask("TestData/testproject.json".ExpandToExecutingPath()); task.Update("notfoundproperty", "test"); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); Assert.StartsWith("Propety notfoundproperty not found in", e.Message); Assert.Equal(3, e.ErrorCode); }
public void MissingFileWithProps() { Context.SetBuildVersion(new Version(1, 1, 2, 2)); UpdateNetCoreVersionTask task = new UpdateNetCoreVersionTask(_path.Object, _file.Object, "nonext.json") .AdditionalProp("dep.test", "dep.test1", "dep.test2"); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); Assert.Equal(3, task.AdditionalProperties.Count); Assert.Equal(1, e.ErrorCode); }
public void FailOnTypeMissmatch() { UpdateJsonFileTask task = new UpdateJsonFileTask("TestData/testproject.json".ExpandToExecutingPath()); task .FailOnTypeMismatch(true) .Update("version", 1); TaskExecutionException e = Assert.Throws <TaskExecutionException>(() => task.ExecuteVoid(Context)); Assert.StartsWith("Propety version type mismatch.", e.Message); Assert.Equal(4, e.ErrorCode); }
public void ShouldReturnFalseIfTaskExecutionExceptionIsThrownByCreator() { // Arrange var command = this.CreateCommand(); var exception = new TaskExecutionException("The task failed to execute"); this.creator.Setup( c => c.Create(It.IsAny <IDatabaseArchive>(), It.IsAny <string>(), It.IsAny <ITaskExecuter>(), It.IsAny <bool>(), It.IsAny <bool>())) .Throws(exception); // Act var result = command.Execute(new[] { "-a", "myArchive" }); // Assert Assert.False(result); }
public void ShouldPrintExceptionMessageIfTaskExecutionExceptionIsThrownByCreator() { // Arrange var command = this.CreateCommand(); var exception = new TaskExecutionException("The task failed to execute"); this.creator.Setup( c => c.Create(It.IsAny <IDatabaseArchive>(), It.IsAny <string>(), It.IsAny <ITaskExecuter>(), It.IsAny <bool>(), It.IsAny <bool>())) .Throws(exception); // Act command.Execute(new[] { "-a", "myArchive" }); // Assert this.messageService.Verify(m => m.WriteLine(exception.Message)); }