public void DeleteSpeakerIsCalledThrowsException() { var speakerRepo = new Mock <ISpeakerRepository>(); var brandRepo = new Mock <IBrandRepository>(); ISpeakerService speakerService = new SpeakerService(speakerRepo.Object, brandRepo.Object); var speaker = new Speaker() { SpeakerId = 1, SpeakerBrand = new Brand() { SpeakerBrand = "test" }, SpeakerDescription = "test", SpeakerName = "test", Color = "test", Price = 1234 }; var isCalled = false; speakerRepo.Setup(x => x.ReadSpeakerById(It.IsAny <int>())).Returns(new Speaker() { SpeakerId = 1, SpeakerBrand = new Brand() { SpeakerBrand = "test" }, SpeakerDescription = "test", SpeakerName = "test", Color = "test", Price = 1234 }); speakerRepo.Setup(x => x.DeleteSpeaker(speaker.SpeakerId)).Callback(() => isCalled = true); speakerService.DeleteSpeaker(speaker.SpeakerId); Assert.True(isCalled); }
public void Delete(int id) { _speakerServ.DeleteSpeaker(id); }