/// <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); }
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(); }
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(); }
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); }
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); }
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); }
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); }
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); }