Exemplo n.º 1
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IDestinationRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Destination>(null));
            var service = new DestinationService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.DestinationModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLDestinationMapperMock,
                                                 mock.DALMapperMockFactory.DALDestinationMapperMock);

            ApiDestinationResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemplo n.º 2
0
        public async void Get_ShouldReturnRecords()
        {
            var mock   = new ServiceMockFacade <IDestinationService, IDestinationRepository>();
            var record = new Destination();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new DestinationService(mock.LoggerMock.Object,
                                                 mock.MediatorMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.DestinationModelValidatorMock.Object,
                                                 mock.DALMapperMockFactory.DALDestinationMapperMock,
                                                 mock.DALMapperMockFactory.DALPipelineStepDestinationMapperMock);

            ApiDestinationServerResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }