public async void Update() { var mock = new ServiceMockFacade <IMessengerRepository>(); var model = new ApiMessengerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Messenger>())).Returns(Task.FromResult(new Messenger())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Messenger())); var service = new MessengerService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MessengerModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLMessengerMapperMock, mock.DALMapperMockFactory.DALMessengerMapperMock); UpdateResponse <ApiMessengerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.MessengerModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiMessengerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <Messenger>())); }
public async void Update_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IMessengerService, IMessengerRepository>(); var model = new ApiMessengerServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Messenger>())).Returns(Task.FromResult(new Messenger())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Messenger())); var service = new MessengerService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.MessengerModelValidatorMock.Object, mock.DALMapperMockFactory.DALMessengerMapperMock); UpdateResponse <ApiMessengerServerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.MessengerModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiMessengerServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <Messenger>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <MessengerUpdatedNotification>(), It.IsAny <CancellationToken>())); }