Exemplo n.º 1
0
        public void EditExistingBug_ShouldReturn200OK_Modify()
        {
            // Arrange -> create a new bug
            var httpPostResponse = TestingEngine.SubmitBugHttpPost("bug title", "description");

            Assert.AreEqual(HttpStatusCode.Created, httpPostResponse.StatusCode);
            var submittedBug = httpPostResponse.Content.ReadAsAsync <BugModel>().Result;

            // Act -> edit the above created bug
            var httpPatchResponse = TestingEngine.EditBugHttpPatch(
                submittedBug.Id, "new title", "new description", "Closed");

            // Assert -> 200 OK
            Assert.AreEqual(HttpStatusCode.OK, httpPatchResponse.StatusCode);

            // Assert the service holds the modified bug
            var httpGetResponse = TestingEngine.HttpClient.GetAsync("/api/bugs/" + submittedBug.Id).Result;
            var bugFromService  = httpGetResponse.Content.ReadAsAsync <BugModel>().Result;

            Assert.AreEqual(HttpStatusCode.OK, httpGetResponse.StatusCode);
            Assert.AreEqual(submittedBug.Id, bugFromService.Id);
            Assert.AreEqual("new title", bugFromService.Title);
            Assert.AreEqual("new description", bugFromService.Description);
            Assert.AreEqual("Closed", bugFromService.Status.ToString());
        }
Exemplo n.º 2
0
        public void CreateBugs_ListBugsByFilter_ShouldReturnsBugsCorrectly()
        {
            // Arrange -> prepare a few bugs
            TestingEngine.CleanDatabase();

            var httpResponseBug1 = TestingEngine.SubmitBugHttpPost("First Bug", null);

            Assert.AreEqual(HttpStatusCode.Created, httpResponseBug1.StatusCode);
            var submittedBug      = httpResponseBug1.Content.ReadAsAsync <BugModel>().Result;
            var httpPatchResponse = TestingEngine.EditBugHttpPatch(
                submittedBug.Id, null, null, "Fixed");

            Assert.AreEqual(HttpStatusCode.OK, httpPatchResponse.StatusCode);
            Thread.Sleep(2);

            var httpResponseBug2 = TestingEngine.SubmitBugHttpPost("Second Bug", "Second Description");

            Assert.AreEqual(HttpStatusCode.Created, httpResponseBug2.StatusCode);
            Thread.Sleep(2);

            var httpResponseBug3 = TestingEngine.SubmitBugHttpPost("Strange Issue", null);

            Assert.AreEqual(HttpStatusCode.Created, httpResponseBug3.StatusCode);
            Thread.Sleep(2);

            // Act -> filter bugs
            var httpResponseFilterBugs = TestingEngine.FilterBugsHttpGet("Bug", "Fixed|Open", null);

            Assert.AreEqual(HttpStatusCode.OK, httpResponseFilterBugs.StatusCode);

            // Assert -> list the bugs and assert their count, order and content are correct
            var bugsFromService = httpResponseFilterBugs.Content.ReadAsAsync <List <BugModel> >().Result;

            Assert.AreEqual(2, bugsFromService.Count());
            Assert.AreEqual("Second Bug", bugsFromService[0].Title);
            Assert.AreEqual("First Bug", bugsFromService[1].Title);
        }