public async System.Threading.Tasks.Task PostProblemNoForm() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemData(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.PostAsync(null, "ProjectId", "ProblemId"); // Assert var result = test as BadRequestResult; Assert.AreEqual(400, result.StatusCode); }
public async System.Threading.Tasks.Task GetAllProblemAsync() { // Throws an error when calling the view this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectDataException(); this._controller = new ProjectSpeedy.Controllers.ProjectsController(this._logger.Object, this._projectService); // Act var test = await this._controller.GetAsync(); // Assert // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt var result = test.Result as ObjectResult; Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task PostNoForm() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._controller = new ProjectSpeedy.Controllers.ProjectController(this._logger.Object, this._projectService); // Act var test = await this._controller.PostAsync(null, "ProjectId"); // Assert // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt var result = test as BadRequestResult; Assert.AreEqual(400, result.StatusCode); }
public async System.Threading.Tasks.Task GetAllAsync() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._controller = new ProjectSpeedy.Controllers.ProjectsController(this._logger.Object, this._projectService); // Act var test = await this._controller.GetAsync(); // Assert // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt var result = test.Result as OkObjectResult; Assert.IsNotNull(result.Value); Assert.AreEqual(1, ((ProjectSpeedy.Models.Projects.ProjectsView)result.Value).rows.Count); }
public async System.Threading.Tasks.Task GetException() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectDataException(); this._controller = new ProjectSpeedy.Controllers.ProjectController(this._logger.Object, this._projectService); // Act var test = await this._controller.GetAsync("ProjectId"); // Assert // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt var result = test.Result as ObjectResult; Assert.IsNull(test.Value); Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task PutExceptionHttpOther() { this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemDataNotFoundOther(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.PutAsync(new ProjectSpeedy.Models.Problem.ProblemNew() { Name = "Name" }, "ProjectId"); // Assert var result = test as ObjectResult; Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task PostProblemDuplicateName() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemData(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.PostAsync(new ProjectSpeedy.Models.Problem.ProblemUpdate() { Name = "Problem Name", }, "ProjectId", "ProblemIdDif"); // Assert var result = test as ObjectResult; Assert.AreEqual(400, result.StatusCode); }
public async System.Threading.Tasks.Task PutNoCreate() { // Throws an error when calling the view this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemDataNoCreate(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.PutAsync(new ProjectSpeedy.Models.Problem.ProblemNew() { Name = "Problem" }, "ProjectId"); // Assert var result = test as ObjectResult; Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task PutNoCreate() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectDataNoCreate(); this._controller = new ProjectSpeedy.Controllers.ProjectController(this._logger.Object, this._projectService); // Act var test = await this._controller.PutAsync(new ProjectSpeedy.Models.Project.ProjectNew() { Name = "New Project Name" }); // Assert // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt var result = test as ObjectResult; Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task PostProblemHttpExceptionOther() { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemDataNotFoundOther(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.PostAsync(new ProjectSpeedy.Models.Problem.ProblemUpdate() { Name = "Name", Description = "Desc" }, "ProjectId", "ProblemId"); // Assert var result = test as ObjectResult; Assert.AreEqual(500, result.StatusCode); }
public async System.Threading.Tasks.Task GetInvalidIds() { using (var stream = new MemoryStream()) { using (var streamBets = new MemoryStream()) { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemData(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.GetAsync("ProjectIdOther", "ProblemId"); // Assert var result = test.Result as NotFoundResult; Assert.IsNull(test.Value); Assert.AreEqual(404, result.StatusCode); } } }
public async System.Threading.Tasks.Task Get() { using (var stream = new MemoryStream()) { using (var streamBets = new MemoryStream()) { // Arrange this._projectService = new ProjectSpeedy.Tests.ServicesTests.ProjectData(); this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemData(); this._controller = new ProjectSpeedy.Controllers.ProblemController(this._logger.Object, this._problemService, this._projectService); // Act var test = await this._controller.GetAsync("ProjectId", "ProblemId"); // Assert var result = test.Result as OkObjectResult; Assert.IsNull(test.Value); Assert.AreEqual(200, result.StatusCode); Assert.AreEqual("Problem Name", ((ProjectSpeedy.Models.Problem.Problem)result.Value).Name); } } }
public ProjectController(ILogger <ProjectController> logger, ProjectSpeedy.Services.IProject projectServices) { this._logger = logger; this._projectServices = projectServices; }
public ProjectsController(ILogger <ProjectsController> logger, Services.IProject projectServices) { _logger = logger; _projectServices = projectServices; }