コード例 #1
0
 public static Entities.Choice Map(Library.Models.Choice choice) => new Entities.Choice
 {
     ChoiceId   = choice.ChoiceId,
     QuestionId = choice.QuestionId,
     Correct    = choice.Correct,
     Choice1    = choice.ChoiceString,
 };
コード例 #2
0
        public async Task <int> CreateChoice(Library.Models.Choice choice)
        {
            if (choice is null)
            {
                throw new ArgumentNullException(nameof(choice));
            }

            _logger.LogInformation($"Adding choice");

            Entities.Choice entity = Mapper.Map(choice);
            _dbContext.Add(entity);
            await _dbContext.SaveChangesAsync();

            return(choice.ChoiceId);
        }
コード例 #3
0
        public async void Check_GameMode()
        {
            IChoiceRepository sut5 = GetInMemoryChoiceRepository();

            Library.Models.Choice choiceA = new Library.Models.Choice
            {
                ChoiceId     = 1,
                QuestionId   = 5,
                Correct      = true,
                ChoiceString = "Hello"
            };
            int c1 = await sut5.CreateChoice(choiceA);

            //int c2 = await sut5.CreateChoice(choiceC);
            Library.Models.Choice choiceB = await sut5.GetChoiceById(1);

            //Assert.True(gms.ToList().Count() == 1);
            Assert.True(choiceB.ChoiceString == "Hello");
            //Assert.True(gm2 == "Hard");
            IEnumerable <Library.Models.Choice> choices = await sut5.GetChoicesByQuestionId(1);

            //Assert.True(choices.ToList().Count() == 2);
        }