public async Task Offices_Delete_ReturnsTrue() { var response = await _controller.Delete(officeId); var result = response as NoContentResult; Assert.That(result.StatusCode, Is.EqualTo(204)); }
public void Offices() { ILogger <OfficeController> _testlogger = null; using (var context = new AppDbContext(options, null)) { var controller = new OfficeController(context, _testlogger); // Get all var result = controller.Get(); // Assert var okResult = Assert.IsAssignableFrom <IEnumerable <Office> >(result); var pgcount = okResult.ToList().Count; Assert.Equal(2, pgcount); // Get by ID var result1 = controller.Get(1); var okResult1 = Assert.IsAssignableFrom <Microsoft.AspNetCore.Mvc.JsonResult>(result1); //var offceresult = JsonConvert.DeserializeObject<Office>(okResult1.ToString()); //Assert.Equal("office 1", offceresult.OfficeName); // test update var pg1 = new Office { OfficeID = 1, OfficeName = "office 1 upd" }; controller.UpdateEntry(pg1); var result3 = controller.Get(1); //Assert.NotEqual("team 1", result3.name); //Assert.Equal("team 1 upd", result3.TeamName); // test delete var result4 = controller.Get(2); //Assert.Equal("team 2", result4.name); IActionResult result5 = controller.Delete(2); var viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkResult>(result5); //var result6 = controller.Get(2); //Assert.Null(result6); } }
public void Office_Delete_Should_Return_Not_Found_If_Office_Was_Deleted() { var result = _officeController.Delete(new int()); Assert.AreEqual(result.StatusCode, HttpStatusCode.NotFound); }