public async void Update() { var mock = new ServiceMockFacade <IFollowerRepository>(); var model = new ApiFollowerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Follower>())).Returns(Task.FromResult(new Follower())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Follower())); var service = new FollowerService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.FollowerModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLFollowerMapperMock, mock.DALMapperMockFactory.DALFollowerMapperMock); UpdateResponse <ApiFollowerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.FollowerModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiFollowerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <Follower>())); }
public async void Update_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IFollowerService, IFollowerRepository>(); var model = new ApiFollowerServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Follower>())).Returns(Task.FromResult(new Follower())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Follower())); var service = new FollowerService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.FollowerModelValidatorMock.Object, mock.DALMapperMockFactory.DALFollowerMapperMock); UpdateResponse <ApiFollowerServerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.FollowerModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiFollowerServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <Follower>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <FollowerUpdatedNotification>(), It.IsAny <CancellationToken>())); }