Example #1
0
        public async Task GetAllWithObjectsAsyncTest()
        {
            //Arrange

            var mock = new Mock <QuestionsService>();

            mock.Setup(x => x.GetAllWithObjectsAsync().Result).Returns(questions);

            var service = new QuestionsService(db);


            //Act

            // var expected = mock;
            var expected = questions;

            var result = await service.GetAllWithObjectsAsync();


            //Assert
            // Assert.Equal(expected, result);
            result.Should().NotBeEmpty();
            result.Should().BeOfType(typeof(List <Question>));
            result.Should().BeSameAs(expected);
        }
Example #2
0
        protected async Task SaveAsync(Question question)
        {
            Question    = question;
            ModalIsOpen = false;

            await _questionsService.AddItemAsync(question);

            Questions = await _questionsService.GetAllWithObjectsAsync();
        }
        protected async Task SaveAsync(Question question)
        {
            Item        = question;
            ModalIsOpen = false;
            Collapse    = true;


            var result = await _questionsService.AddAnswerToQuestion(question);

            if (result != null)
            {
                Items = await _questionsService.GetAllWithObjectsAsync();
            }
        }
Example #4
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _questionsService = (QuestionsService)ScopedServices.GetRequiredService(typeof(QuestionsService));

            // _answersService = (AnswersService) ScopedServices.GetService(typeof(AnswersService));
            // _usersService = (UsersService) ScopedServices.GetService(typeof(UsersService));
            if (Questions == null)
            {
                // await InitQuestionData();
            }

            Questions = await _questionsService.GetAllWithObjectsAsync();

            // Answers = await _answersService.GetAllAsync();
            // Users = await _usersService.GetAllAsync();

            // ModalIsOpen = false;
        }