public void Cannot_Delete_Nonexistent_Sound() { // Arrange - creating a sound var sound = new TimerSound { Name = "Apple", Data = new byte[] { 0x01 }, ID = 1 }; // Arrange - create the mock repository var mockRepository = new Mock <IRepository <TimerSound> >(); mockRepository.Setup(m => m.GetAll()).Returns(new[] { new TimerSound { Name = "Orange", Data = new byte[] { 0x04 }, ID = 2 }, new TimerSound { Name = "Cabbage", Data = new byte[] { 0x07 }, ID = 3 }, }.AsQueryable()); // Arrange - create a controller var target = new TimerController(null, mockRepository.Object, null); // Act - delete the product var result = target.DeleteSound(sound.ID); // Assert - ensure that the repository delete method was // called with the correct Product mockRepository.Verify(m => m.Delete(sound.ID)); Assert.Equal(2, mockRepository.Object.GetAll().Count()); }