public async void Update() { var mock = new ServiceMockFacade <IRowVersionCheckRepository>(); var model = new ApiRowVersionCheckRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <RowVersionCheck>())).Returns(Task.FromResult(new RowVersionCheck())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new RowVersionCheck())); var service = new RowVersionCheckService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.RowVersionCheckModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLRowVersionCheckMapperMock, mock.DALMapperMockFactory.DALRowVersionCheckMapperMock); UpdateResponse <ApiRowVersionCheckResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.RowVersionCheckModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiRowVersionCheckRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <RowVersionCheck>())); }
public async void Update_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IRowVersionCheckService, IRowVersionCheckRepository>(); var model = new ApiRowVersionCheckServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <RowVersionCheck>())).Returns(Task.FromResult(new RowVersionCheck())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new RowVersionCheck())); var service = new RowVersionCheckService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.RowVersionCheckModelValidatorMock.Object, mock.DALMapperMockFactory.DALRowVersionCheckMapperMock); UpdateResponse <ApiRowVersionCheckServerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.RowVersionCheckModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiRowVersionCheckServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <RowVersionCheck>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <RowVersionCheckUpdatedNotification>(), It.IsAny <CancellationToken>())); }