public async Task Run_ReturnsNoContentOnSuccess() { var handler = new Mock <ICommandHander <DeleteTaskCommand> >(); var container = new Container(); var request = new DefaultHttpRequest(new DefaultHttpContext()); var listId = Guid.NewGuid().ToString(); var taskId = Guid.NewGuid().ToString(); handler.Setup(h => h.Execute(It.IsAny <DeleteTaskCommand>())).Returns(Task.CompletedTask); container.RegisterInstance(handler.Object); container.RegisterInstance(_telemetryClient); DeleteTask.Container = container; var result = await DeleteTask.Run(request, listId, taskId) as NoContentResult; Assert.IsNotNull(result); }
public async Task Run_ReturnsServerErrorOnServerError() { var handler = new Mock <ICommandHander <DeleteTaskCommand> >(); var container = new Container(); var request = new DefaultHttpRequest(new DefaultHttpContext()); var listId = Guid.NewGuid().ToString(); var taskId = Guid.NewGuid().ToString(); handler.Setup(h => h.Execute(It.IsAny <DeleteTaskCommand>())) .ThrowsAsync(new Exception()); container.RegisterInstance(handler.Object); container.RegisterInstance(_telemetryClient); DeleteTask.Container = container; var result = await DeleteTask.Run(request, listId, taskId) as InternalServerErrorResult; Assert.IsNotNull(result); }
public void DeleteFile(string path) { DeleteTask t = new DeleteTask(path); t.Run(); this.history.Push(t); }