コード例 #1
0
        protected async Task Delete(int id, string expectedResultName, BaseController <T> controller)
        {
            // Act
            var response = await controller.Delete(id);

            // Assert
            Assert.True(response.Result.GetType().Name == expectedResultName, $"It was expected that this test case would have a '{expectedResultName}' return, however it did not. Actual result type: {response.Result.GetType()}.");
        }
コード例 #2
0
        public void DeleteUserById()
        {
            var baseRepository = _controllerFixture.Setup();

            _baseController = new BaseController <User>(baseRepository.Object);
            baseRepository.Setup(x => x.Delete(1));
            _baseController.Delete(5);
            User userToDelete = _controllerFixture.Users.Find(x => x.ID == 5);

            _controllerFixture.Users.Remove(userToDelete);
            Assert.Equal(3, _controllerFixture.Users.Count);
        }
コード例 #3
0
        public void Should_return_no_content_when_delete_called()
        {
            var result = _userController.Delete(1234);

            Assert.IsInstanceOf <NoContentResult>(result);
        }
コード例 #4
0
ファイル: projectsController.cs プロジェクト: Styxer/RestAPi
 // DELETE: api/projects/5
 public void Delete(int id)
 {
     baseRepo.Delete(id, repo);
 }