예제 #1
0
파일: PartForm.cs 프로젝트: oghenez/profitz
 public void Delete(object obj, EventArgs e)
 {
     try
     {
         if (m_part.ID > 0)
         {
             this.Cursor = Cursors.WaitCursor;
             if (KryptonMessageBox.Show("Are you sure to delete this record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
             {
                 this.Cursor = Cursors.Default; return;
             }
             r_part.Delete(m_part);
             removeRecord(m_part.ID);
             ClearForm();
             setEnableForm(true);
             setEditMode(EditMode.New);
             textBoxCode.Focus();
             this.Cursor = Cursors.Default;
         }
     }
     catch (Exception x)
     {
         KryptonMessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
예제 #2
0
        public async void TestPartRepoForDelete()
        {
            // arrange
            int indexCpu = 5;
            var repo     = new PartRepository <Cpu>(_context, _mapper);
            var expected = MockData.Cpus.Where(c => c.Id == indexCpu).FirstOrDefault();

            // act
            var result = await repo.Delete(indexCpu);

            // assert
            Assert.Equal(expected.Id, result.Id);
        }
        public void Delete_GivenExistingPart_ShouldDeleteAndSave()
        {
            //---------------Set up test pack-------------------
            var part           = new PartBuilder().WithNewId().BuildSaved();
            var parts          = Broker.GetBusinessObjectCollection <Part>("");
            var userRepository = new PartRepository();

            Assert.AreEqual(1, parts.Count);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            userRepository.Delete(part);
            //---------------Test Result -----------------------
            Assert.AreEqual(0, parts.Count);
        }