public async void Update() { var mock = new ServiceMockFacade <IDirectTweetRepository>(); var model = new ApiDirectTweetRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DirectTweet>())).Returns(Task.FromResult(new DirectTweet())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new DirectTweet())); var service = new DirectTweetService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DirectTweetModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDirectTweetMapperMock, mock.DALMapperMockFactory.DALDirectTweetMapperMock); UpdateResponse <ApiDirectTweetResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.DirectTweetModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiDirectTweetRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <DirectTweet>())); }
public async void Update_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IDirectTweetService, IDirectTweetRepository>(); var model = new ApiDirectTweetServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DirectTweet>())).Returns(Task.FromResult(new DirectTweet())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new DirectTweet())); var service = new DirectTweetService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DirectTweetModelValidatorMock.Object, mock.DALMapperMockFactory.DALDirectTweetMapperMock); UpdateResponse <ApiDirectTweetServerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.DirectTweetModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiDirectTweetServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <DirectTweet>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DirectTweetUpdatedNotification>(), It.IsAny <CancellationToken>())); }