public async Task TestGetQuizMetadata()
        {
            const int numberOfQuizzes = 7;

            var quizMetadataList = await _quizMetadataService.GetQuizMetadataAsync(numberOfQuizzes);

            Assert.AreEqual(numberOfQuizzes, quizMetadataList.Count);
        }
        public void TestGetQuizMetadata()
        {
            const int numberOfQuizzes = 7;

            var request = _quizMetadataService.GetQuizMetadataAsync(numberOfQuizzes);

            request.Wait();
            Assert.AreEqual(numberOfQuizzes, request.Result.Count);
        }
        public void TestGetQuizMetadata()
        {
            var request = _quizMetadataService.GetQuizMetadataAsync(7);

            request.Wait();
            Assert.AreEqual(7, request.Result.Count);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <List <QuizMetadata> > > GetQuizMetadataAsync([FromQuery] int count = DefaultQuizCount)
        {
            try
            {
                var quizMetadata = await _quizMetadataService.GetQuizMetadataAsync(count);

                return(Ok(quizMetadata));
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error occurred: {e}");
                return(StatusCode(500, new Error(e)));
            }
        }
        public async Task GivenScraperServiceReturnsContent_WhenGetQuizAsyncWithNullId_ThenExpectedQuizReturned()
        {
            // Given
            _mockQuizMetadataService.GetQuizMetadataAsync(1).Returns(new List <QuizMetadata>
            {
                _quizMetadata
            });
            _mockScraperHttpService.GetQuizPageContentAsync(TestQuizId).Returns(TestHtmlContent);
            _mockHtmlService.FindQuestions(TestHtmlContent).Returns(_questions);
            // When
            var quiz = await _quizService.GetQuizAsync();

            // Then
            Assert.AreEqual(TestQuizId, quiz.Id);
            Assert.AreEqual(TestQuizDate, quiz.Date);
            Assert.AreEqual(TestQuizTitle, quiz.Title);
            Assert.AreEqual(_questions, quiz.Questions);
        }
Exemplo n.º 6
0
        public async Task <Quiz> GetQuizAsync(string id = null)
        {
            QuizMetadata quizMetadata;

            if (id == null)
            {
                var quizMetadataList = await _quizMetadataService.GetQuizMetadataAsync(1);

                quizMetadata = quizMetadataList.First();
            }
            else
            {
                quizMetadata = new QuizMetadata
                {
                    Id   = id,
                    Date = DateTime.UtcNow
                };
            }

            return(await GetQuizAsync(quizMetadata));
        }
        public async Task TestGetQuizMetadata()
        {
            var quizMetadataList = await _quizMetadataService.GetQuizMetadataAsync(7);

            Assert.AreEqual(7, quizMetadataList.Count);
        }