public async Task <IActionResult> Delete(int id)
 {
     if (ModelState.IsValid)
     {
         return(Ok(await _service.Delete(id)));
     }
     return(BadRequest());
 }
        public void _006_TestOptionDelete()
        {
            var ServiceObject = new OptionService();
            var ArgsObject    = new OptionDeleteServiceOptions();

            ArgsObject.option_id = option_id;
            var result = ServiceObject.Delete(ArgsObject);

            Assert.IsInstanceOf <TwoCheckoutResponse>(result);
        }
        public void Delete_Option_Success()
        {
            Mock <IOptionRepository> mockRepository = new Mock <IOptionRepository>(MockBehavior.Loose);

            mockRepository.Setup(s => s.Delete(1));

            OptionService service = new OptionService(mockRepository.Object);

            service.Delete(1);

            mockRepository.Verify(m => m.Delete(It.IsAny <int>()), Times.Once());
        }
示例#4
0
        public async Task Delete()
        {
            //Arrange
            var expected = 1;
            //Act
            var result = await _service.Delete(expected);

            var agent = await _service.GetById(expected);

            //Assert
            result.Should().Be(true);
            agent.Should().BeNull();
        }
        public async Task DeleteOption()
        {
            // Arrange
            var expected = 1;

            // Act
            var result = await _service.Delete(expected);

            var option = await _service.Get(expected);

            // Assert
            result.Should().Be(true);
            option.Should().BeNull();
        }
        public async Task DeleteOption()
        {
            // Arrange
            var expected = 6;

            // Act
            var result = await _service.Delete(expected);

            var match = await _service.GetById(expected);

            // Assert
            result.Should().Be(true);
            match.Should().BeNull();
        }
        public void Delete_Option_Not_Found_Error()
        {
            Mock <IOptionRepository> mockRepository = new Mock <IOptionRepository>(MockBehavior.Strict);

            mockRepository.Setup(s => s.Delete(666))
            .Throws(new DbUpdateException("The current option does not exist.", new NullReferenceException()));

            OptionService service = new OptionService(mockRepository.Object);

            DbUpdateException ex = Assert.Throws <DbUpdateException>(() => service.Delete(666));

            Assert.NotNull(ex);
            Assert.Equal("The current option does not exist.", ex.Message);

            mockRepository.Verify(m => m.Delete(It.IsAny <int>()), Times.Once());
        }