public async void Update() { var mock = new ServiceMockFacade <IOtherTransportRepository>(); var model = new ApiOtherTransportRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <OtherTransport>())).Returns(Task.FromResult(new OtherTransport())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new OtherTransport())); var service = new OtherTransportService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.OtherTransportModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLOtherTransportMapperMock, mock.DALMapperMockFactory.DALOtherTransportMapperMock); UpdateResponse <ApiOtherTransportResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.OtherTransportModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiOtherTransportRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <OtherTransport>())); }
public async void Update_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IOtherTransportService, IOtherTransportRepository>(); var model = new ApiOtherTransportServerRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <OtherTransport>())).Returns(Task.FromResult(new OtherTransport())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new OtherTransport())); var service = new OtherTransportService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.OtherTransportModelValidatorMock.Object, mock.DALMapperMockFactory.DALOtherTransportMapperMock); UpdateResponse <ApiOtherTransportServerResponseModel> response = await service.Update(default(int), model); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.ModelValidatorMockFactory.OtherTransportModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiOtherTransportServerRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <OtherTransport>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <OtherTransportUpdatedNotification>(), It.IsAny <CancellationToken>())); }