Example #1
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IQuoteTweetService, IQuoteTweetRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <QuoteTweet>(null));
            var service = new QuoteTweetService(mock.LoggerMock.Object,
                                                mock.MediatorMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.QuoteTweetModelValidatorMock.Object,
                                                mock.DALMapperMockFactory.DALQuoteTweetMapperMock);

            ApiQuoteTweetServerResponseModel 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 <IQuoteTweetRepository>();
            var record = new QuoteTweet();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new QuoteTweetService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.QuoteTweetModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLQuoteTweetMapperMock,
                                                mock.DALMapperMockFactory.DALQuoteTweetMapperMock);

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

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