/// <summary> /// Initializes a new instance of the <see cref="TextMessageHandler" /> class. /// </summary> /// <param name="processor">The message processor.</param> public TextMessageHandler(MessageProcessorService processor) : base(processor) { this.witAiToken = Environment.GetEnvironmentVariable("WITAI_TOKEN"); if (this.witAiToken == null) { throw new Exception("Cannot find WITAI_TOKEN in this env."); } }
/// <summary> /// Initializes a new instance of the FacebookController class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="processor">The message processor.</param> public FacebookController(ILogger <FacebookController> logger, MessageProcessorService processor) { this.logger = logger; this.processor = processor; this.verifyToken = Environment.GetEnvironmentVariable("VERIFY_TOKEN"); if (this.verifyToken == null) { throw new Exception("Cannot find VERIFY_TOKEN in this env."); } }
public void ProcessMessage_WhenProcessorExists_ShouldRaiseProcessorNotFoundException() { // Arrange var username = "******"; Message message = new PublicMessageRequest("Hello"); var logger = Substitute.For <ILogger <MessageProcessorService> >(); var serviceProvider = Substitute.For <IServiceProvider>(); var mockProcessor = Substitute.For <IMessageProcessor <PublicMessageRequest> >(); serviceProvider.GetService(Arg.Any <Type>()).Returns(null); MessageProcessorService messageProcessorService = new MessageProcessorService(logger, serviceProvider); // Act / Assert Assert.Throws <ProcessorNotFoundException>(() => messageProcessorService.ProcessMessage(username, message)); }
public void ProcessMessage_WhenProcessorExists_ShouldProcessMessage() { // Arrange var username = "******"; Message message = new PublicMessageRequest("Hello"); var logger = Substitute.For <ILogger <MessageProcessorService> >(); var serviceProvider = Substitute.For <IServiceProvider>(); var mockProcessor = Substitute.For <IMessageProcessor <PublicMessageRequest> >(); serviceProvider.GetService(Arg.Is(typeof(IMessageProcessor <PublicMessageRequest>))).Returns(mockProcessor); MessageProcessorService messageProcessorService = new MessageProcessorService(logger, serviceProvider); // Act messageProcessorService.ProcessMessage(username, message); // Assert mockProcessor.Received(1).HandleMessage(username, message); }
/// <summary> /// Initializes a new instance of the <see cref="HelpMessageHandler" /> class. /// </summary> /// <param name="processor">The message processor.</param> public HelpMessageHandler(MessageProcessorService processor) : base(processor) { }
public TransfersController(ConfigurationRepository repository, MessageProcessorService messengerService) { this.repository = repository; this.messengerService = messengerService; }
/// <summary> /// Initializes a new instance of the <see cref="MessageHandler" /> class. /// </summary> /// <param name="processor">The message processor.</param> public MessageHandler(MessageProcessorService processor) { this.Processor = processor; }