コード例 #1
0
        public async Task GetAllSuggestions_WithNoData_ShouldReturnEmptyList()
        {
            var options = new DbContextOptionsBuilder <QuizaldoDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            var context = new QuizaldoDbContext(options);

            var questionSuggestionService = new QuestionSuggestionService(context, mapper, notificationService);

            var result = await questionSuggestionService.GetAllSuggestions();

            Assert.True(result.Count() == 0);
        }
コード例 #2
0
        public async Task RemoveSuggestion_WithIncorrectData_ShouldntRemoveSuggestion(int questionSuggestionId)
        {
            var options = new DbContextOptionsBuilder <QuizaldoDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            var context = new QuizaldoDbContext(options);

            var questionSuggestionService = new QuestionSuggestionService(context, mapper, notificationService);

            SeedTestQuestionSuggestion(context);

            await questionSuggestionService.RemoveSuggestion(questionSuggestionId);

            Assert.Equal(1, context.QuestionSuggestions.Count());
        }
コード例 #3
0
        public async Task SuggestQuestion_WithCorrectInputDataAndIncorretUser_ShouldntReturnQuestion(string username)
        {
            var options = new DbContextOptionsBuilder <QuizaldoDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            var context = new QuizaldoDbContext(options);

            var questionSuggestionService = new QuestionSuggestionService(context, mapper, notificationService);

            var question = GetTestQuestionSuggestion();

            SeedTestUser(context);

            await questionSuggestionService.SuggestQuestion(question, username);

            Assert.Equal(0, context.QuestionSuggestions.Count());
        }
コード例 #4
0
        public async Task ApproveSuggestion_WithCorrectData_ShouldAddQuestion(int questionSuggestionId)
        {
            var options = new DbContextOptionsBuilder <QuizaldoDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            var context = new QuizaldoDbContext(options);

            var config = new MapperConfiguration(opts =>
            {
                opts.CreateMap <Question, QuestionSuggestion>().ReverseMap();
            });

            var mapper = config.CreateMapper();

            var questionSuggestionService = new QuestionSuggestionService(context, mapper, notificationService);

            SeedTestQuestionSuggestion(context);

            await questionSuggestionService.ApproveSuggestion(questionSuggestionId);

            Assert.Equal(0, context.QuestionSuggestions.Count());
        }