Esempio n. 1
0
        /// <summary>
        /// Handles the main asynchronous execution and handling of command events.
        /// </summary>
        private static async Task MainAsync(string token)
        {
            // Set up client
            var discord = new DiscordClient(new DiscordConfiguration()
            {
                Token           = token,
                TokenType       = TokenType.Bot,
                MinimumLogLevel = LogLevel.Debug
            });

            // Set up command prefix
            discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new[] { "!" }
            });

            // Register module controllers
            TagController.Register(discord);
            ModerationController.Register(discord);
            MiscController.Register(discord);

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
Esempio n. 2
0
        public void Question_ShouldRenderView(int id)
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();
            var mockQuestionService   = new Mock <IQuestionUtility>();
            var mockViewModelFactory  = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act && Assert
            controller.WithCallTo(x => x.Question(id)).ShouldRenderDefaultView();
        }
Esempio n. 3
0
        public void Submissions_ShouldRenderView(int count, int page)
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();
            var mockQuestionService   = new Mock <IQuestionUtility>();
            var mockViewModelFactory  = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act && Assert
            controller.WithCallTo(x => x.Submissions(count, page)).ShouldRenderDefaultView();
        }
Esempio n. 4
0
        public void Constructor_ShouldInitializeCorrectly()
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();
            var mockQuestionService   = new Mock <IQuestionUtility>();
            var mockViewModelFactory  = new Mock <IViewModelFactory>();

            // Act
            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            // Assert
            Assert.IsNotNull(controller);
        }
Esempio n. 5
0
        public void Question_ShouldCallQuestionService_GetById(int id)
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();
            var mockQuestionService   = new Mock <IQuestionUtility>();
            var mockViewModelFactory  = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act
            controller.Question(id);

            //Assert
            mockQuestionService.Verify(x => x.GetById(id), Times.Once);
        }
Esempio n. 6
0
        public void Submissions_ShouldCallModerationService_GetPendingSubmissions()
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();
            var mockQuestionService   = new Mock <IQuestionUtility>();
            var mockViewModelFactory  = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act
            controller.Submissions();

            //Assert
            mockModerationService.Verify(x => x.GetPendingSubmissions(), Times.Once);
        }
Esempio n. 7
0
        public void Approve_ShouldRenderView(int id)
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();

            mockModerationService.Setup(x => x.Approve(id)).Returns(new Question {
                Id = 0
            });

            var mockQuestionService  = new Mock <IQuestionUtility>();
            var mockViewModelFactory = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act && Assert
            controller.WithCallTo(x => x.Approve(id)).ShouldRedirectTo(x => x.Question);
        }
Esempio n. 8
0
        public void Approve_ShouldCallModerationService_Approve(int id)
        {
            // Arrange
            var mockModerationService = new Mock <IModerationService>();

            mockModerationService.Setup(x => x.Approve(id)).Returns(new Question {
                Id = 0
            });

            var mockQuestionService  = new Mock <IQuestionUtility>();
            var mockViewModelFactory = new Mock <IViewModelFactory>();

            var controller = new ModerationController(mockModerationService.Object,
                                                      mockQuestionService.Object,
                                                      mockViewModelFactory.Object);

            //Act
            controller.Approve(id);

            //Assert
            mockModerationService.Verify(x => x.Approve(id), Times.Once);
        }