public void DeleteGuest_IsNotNull() { //Arrenge var guestViewModel = new GuestViewModel(); var guestRepoMock = new Mock <IGuestRepository>(); guestRepoMock.Setup(r => r.DeleteGuests(It.IsAny <int>())).Returns(new Guest()); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); var guestService = new GuestService(mapper, guestRepoMock.Object); //Act var result = guestService.DeleteGuests(guestViewModel.Id); //Assert Assert.IsNotNull(result); }
public void DeleteGuest_Success_CallsRepositoryWithCorrectParameters() { //Arrenge var guestViewModel = new GuestViewModel() { Id = 1 }; var guestRepoMock = new Mock <IGuestRepository>(); guestRepoMock.Setup(r => r.DeleteGuests(It.IsAny <int>())).Returns(new Guest()); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); var guestService = new GuestService(mapper, guestRepoMock.Object); //Act var result = guestService.DeleteGuests(guestViewModel.Id); //Assert guestRepoMock.Verify(r => r.DeleteGuests(It.Is <int>(id => id == guestViewModel.Id)), Times.Once); }