Example #1
0
        public void Delete_Valid()
        {
            IActionResult result = controller.Delete(1);

            Assert.NotNull(result);
            Assert.AreEqual((result as OkObjectResult).StatusCode, 200);
        }
        public void Delete_When_id_is_not_exist_Then_return_status_code_404()
        {
            var service    = A.Fake <IService <PilotDto> >();
            var notExistId = 8485;

            A.CallTo(() => service.Delete(notExistId)).Throws(new NotExistException());
            var controller = new PilotsController(service);
            var id         = notExistId;

            var result = controller.Delete(id) as StatusCodeResult;

            Assert.AreEqual(404, result.StatusCode);
        }
        public void Delete_When_id_is_exist_Then_return_status_code_204()
        {
            var service = A.Fake <IService <PilotDto> >();
            var existId = 1;

            A.CallTo(() => service.Delete(existId));
            var controller = new PilotsController(service);
            var id         = existId;

            var result = controller.Delete(id) as StatusCodeResult;

            Assert.AreEqual(204, result.StatusCode);
        }
        public void DELETE_WhenDeleteItem_ThenServiceReturnNoContent()
        {
            //Arrange
            var id = Guid.NewGuid();

            var fakeService = A.Fake <IPilotService>();

            var controller = new PilotsController(fakeService);

            //Act
            var response = controller.Delete(id) as NoContentResult;

            //Assert
            Assert.AreEqual((int)HttpStatusCode.NoContent, response.StatusCode);
        }