public async void Get_ShouldReturnNullBecauseRecordNotFound() { var mock = new ServiceMockFacade <IPenService, IPenRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Pen>(null)); var service = new PenService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.PenModelValidatorMock.Object, mock.DALMapperMockFactory.DALPenMapperMock, mock.DALMapperMockFactory.DALPetMapperMock); ApiPenServerResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Get() { var mock = new ServiceMockFacade <IPenRepository>(); var record = new Pen(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new PenService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.PenModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLPenMapperMock, mock.DALMapperMockFactory.DALPenMapperMock, mock.BOLMapperMockFactory.BOLPetMapperMock, mock.DALMapperMockFactory.DALPetMapperMock); ApiPenResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }