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 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 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); }