public void Update_CallDto() { // Setup dependence var settingMock = new Mock<ISettings>(); var componentMock = new Mock<IComponents>(); var repositoryMock = new Mock<IRepository>(); var uowMock = new Mock<IUnitOfWork>(); var serviceLocatorMock = new Mock<IServiceLocator>(); serviceLocatorMock.Setup(r => r.GetInstance<IRepository>()) .Returns(repositoryMock.Object); serviceLocatorMock.Setup(r => r.GetInstance<IUnitOfWork>()) .Returns(uowMock.Object); ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object); repositoryMock.Setup(r => r.CreateUnitOfWork()).Returns(uowMock.Object); // Arrange data Guid id = Guid.NewGuid(); CallDto callDto = new CallDto { Id = id }; // Act CallService callService = new CallService(uowMock.Object, repositoryMock.Object, settingMock.Object, componentMock.Object); var currentCall = callService.Update(callDto); // Assert repositoryMock.Verify(r => r.Update<Call>( It.Is<Call>(b => b.Id == id))); uowMock.Verify(u => u.Save()); }