示例#1
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string MACHINE_CD = shtView.GetValue(shtView.ActiveRowIndex, (int)eColView.MACHINE_CD).ToString();

                MachineValidator validator = new MachineValidator();
                ErrorItem        errorItem = null;
                errorItem = validator.ValidateBeforeDelete(MACHINE_CD.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo);
                if (dr == MessageDialogResult.No)
                {
                    return;
                }


                m_machineController.DeleteMachine(MACHINE_CD.ToNZString());
                LoadData(false);

                MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
示例#2
0
        public async Task DeleteMachine_Should_Returns_0_when_no_data_was_deleted()
        {
            //Arrange
            var machineService = new Mock <IMachineServices>();
            var logger         = new Mock <ILogger <MachineController> >();

            machineService.Setup(x => x.DeleteMachine(It.IsAny <int>())).ThrowsAsync(new MachineNotFoundException());

            var machineController = new MachineController(machineService.Object, logger.Object);

            //Act
            var actionResult = await machineController.DeleteMachine(1) as ObjectResult;

            // Assert
            Assert.NotNull(actionResult);
            Assert.IsAssignableFrom <ObjectResult>(actionResult);
            Assert.IsType <int>(actionResult.Value);
            Assert.Equal(StatusCodes.Status404NotFound, actionResult.StatusCode);
            Assert.Equal(0, actionResult.Value);
        }
示例#3
0
        public async Task DeleteMachine_Should_Responsed_WithOk()
        {
            //Arrange
            var machineService = new Mock <IMachineServices>();
            var logger         = new Mock <ILogger <MachineController> >();

            machineService.Setup(x => x.DeleteMachine(It.IsAny <int>())).ReturnsAsync(1);

            var machineController = new MachineController(machineService.Object, logger.Object);

            //Act
            var actionResult = await machineController.DeleteMachine(1) as ObjectResult;

            // Assert
            Assert.NotNull(actionResult);
            Assert.IsAssignableFrom <ObjectResult>(actionResult);
            Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode);
            Assert.IsType <int>(actionResult.Value);
            Assert.Equal(1, actionResult.Value);
        }