public void Delete_Should_Delete_Data_And_Should_Return_Null(Mock <ISessionManager> mockSessionManager, DefaultSession session, Dummy data)
        {
            //Arrange
            mockSessionManager.Setup(m => m.Current)
            .Returns(session);

            var options = new DbContextOptionsBuilder <DummyContext>()
                          .UseInMemoryDatabase("DummyDb")
                          .Options;

            var context    = new DummyContext(options, mockSessionManager.Object);
            var repository = new WriteRepository <DummyContext, Dummy>(context);

            repository.Add(data);

            //Act
            repository.Delete(data.Id);

            //Assert
            Dummy dummyData = repository.GetById(data.Id);

            dummyData.Should().BeNull();

            context.Dispose();
        }
 private void buttonDeleteSelectedMenuProduct_Click(object sender, EventArgs e)
 {
     if ((_currentTable == "menuproducts") && (dataGridViewRestaurantManagementSystem.SelectedRows.Count > 0))
     {
         var menuProductId = dataGridViewRestaurantManagementSystem.SelectedRows[0].Cells["ID"].Value.ToString();
         _writeMenuProductRepository.Delete(_readMenuProductRepository.GetByID(int.Parse(menuProductId)));
         ShowMenuProducts();
         ClearTextBoxes();
     }
     else
     {
         MessageBox.Show(@"Aby usunąc produkt menu w pierwszej kolejności musisz jakiś wybrać!");
     }
     ClearTextBoxes();
 }
 private void buttonDeleteSelectedSupply_Click(object sender, EventArgs e)
 {
     if ((_currentTable == "supplies") && (dataGridViewRestaurantManagementSystem.SelectedRows.Count > 0))
     {
         var supplyId = dataGridViewRestaurantManagementSystem.SelectedRows[0].Cells["ID"].Value.ToString();
         _writeSupplyRepository.Delete(_readSupplyRepository.GetByID(int.Parse(supplyId)));
         ShowSupplies();
         ClearTextBoxes();
     }
     else
     {
         MessageBox.Show(@"Aby usunąc dostawce w pierwszej kolejności musisz jakiegoś wybrać!");
     }
     ClearTextBoxes();
 }
예제 #4
0
        public async Task DeleteSprintAsync(int sprintId)
        {
            var sprint = await ReadRepository.Query.SingleOrDefaultAsync(s => s.Id == sprintId);

            WriteRepository.Delete(sprint);
        }
예제 #5
0
        public async Task DeleteBacklogItemAsync(int backlogItemId)
        {
            var backlogItem = await ReadRepository.Query.SingleOrDefaultAsync(b => b.Id == backlogItemId);

            WriteRepository.Delete(backlogItem);
        }