public void EditExistingBug_NoDataSend_ShouldReturn400BadRequest() { // Arrange -> create a new bug var data = new BugTrackerDataMock(); var bug = new Bug() { Id = 1, Title = "test", Status = Status.Open }; data.Bugs.Add(bug); var controller = new BugsController(data); this.SetupControllerForTesting(controller, "bugs"); // Act -> edit the above created bug var httpResponse = controller.PatchEditBug(1, null) .ExecuteAsync(new CancellationToken()).Result; // Assert -> 404 Not found Assert.AreEqual(HttpStatusCode.BadRequest, httpResponse.StatusCode); }
public void EditExistingBugTitle_ShouldReturn200OK_Modify() { // Arrange -> create a new bug var data = new BugTrackerDataMock(); var bug = new Bug() { Id = 1, Title = "test", Status = Status.Open }; data.Bugs.Add(bug); var controller = new BugsController(data); this.SetupControllerForTesting(controller, "bugs"); // Act -> edit the above created bug var httpResponse = controller.PatchEditBug(1, new BugBindingEditBugModel() { Title = "test1" }) .ExecuteAsync(new CancellationToken()).Result; // Assert -> 200 OK Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode); // Assert the service holds the modified bug Assert.AreEqual("test1", bug.Title); Assert.AreEqual(Status.Open, bug.Status); }
public void EditNonExistingBug_ShouldReturn404NotFound() { // Arrange -> create a new bug var data = new BugTrackerDataMock(); var controller = new BugsController(data); this.SetupControllerForTesting(controller, "bugs"); // Act -> edit the above created bug var httpResponse = controller.PatchEditBug(1, new BugBindingEditBugModel() { Description = "Bomba", Status = "Closed" }) .ExecuteAsync(new CancellationToken()).Result; // Assert -> 404 Not found Assert.AreEqual(HttpStatusCode.NotFound, httpResponse.StatusCode); }