public void IncludeBotEvents_Should_Be_Equal(bool includeBotEvents) { // Arrange _sut = new TestHandler(null, new List <string>(), includeBotEvents); // Assert _sut.IncludeBotEvents.Should().Be(includeBotEvents); }
public void EventName_Should_Be_Equal(string eventName) { // Arrange _sut = new TestHandler(eventName, new List <string>(), false); // Assert _sut.EventName.Should().Be(eventName); }
public void Action_Should_Be_Equal(string action) { // Arrange _sut = new TestHandler(null, new List <string>() { action }, false); // Assert _sut.Actions.Should().Contain(action); }
/// <summary> /// Sends an embed to a specific channel /// </summary> /// <param name="content">message content</param> /// <param name="webhook">Use webhook or message</param> /// <param name="webhookUser">Webhook username</param> private static void SendEmbed(DiscordHandler client, ICommand cmd, CommandEventArg args, DiscordEmbed embed, string content, ulong channelId, DiscordGuild guild, bool webhook, string webhookUser, string webhookAvatar = null) { DiscordChannel channel; try { channel = guild.GetChannel(channelId); } catch (DSharpPlus.Exceptions.NotFoundException) { throw new ReadableCmdException("Could not find the discord channel"); } //TODO: make it so webhook and default can both send up to 5 embeds max at once if (webhook) { try { using (WebHookHandler whh = new WebHookHandler(channel, webhookUser, webhookAvatar)) { whh.SendEmbed(content, new DiscordEmbed[] { embed }).ConfigureAwait(false).GetAwaiter().GetResult(); } } catch (UriFormatException) { HelpCommand.ShowHelp(args.Channel, cmd, "Invalid link"); return; } } else { channel.SendMessageAsync(content: content, embed: embed).ConfigureAwait(false).GetAwaiter().GetResult(); } client.SendSimpleEmbed(args.Channel, "Sent Embed").ConfigureAwait(false); }
private static void TestUpdate <T>(string body, IObserver <T> observer) { var handler = new WebHookHandler(); #pragma warning disable CS1702 // Assuming assembly reference matches identity var scheduler = new TestScheduler(); var inlineObserver = new MockObserver <InlineEvent>(scheduler); handler.InlineEvents.Subscribe(inlineObserver); if (typeof(T) == typeof(InlineEvent)) { handler.InlineEvents.Subscribe((IObserver <InlineEvent>)observer); } var messageObserver = new MockObserver <MessageEvent>(scheduler); handler.MessageEvents.Subscribe(messageObserver); if (typeof(T) == typeof(MessageEvent)) { handler.MessageEvents.Subscribe((IObserver <MessageEvent>)observer); } var paymentObserver = new MockObserver <PaymentEvent>(scheduler); handler.PaymentEvents.Subscribe(paymentObserver); if (typeof(T) == typeof(PaymentEvent)) { handler.PaymentEvents.Subscribe((IObserver <PaymentEvent>)observer); } var response = handler.Process(body); #pragma warning restore CS1702 // Assuming assembly reference matches identity Assert.IsTrue(response.Ok); Assert.IsNull(response.ErrorCode); if (typeof(T) == typeof(InlineEvent)) { Assert.IsNotEmpty(inlineObserver.Messages); var notification = inlineObserver.Messages[0].Value; Assert.IsTrue(notification.HasValue); } else { Assert.IsEmpty(inlineObserver.Messages); } if (typeof(T) == typeof(PaymentEvent)) { Assert.IsNotEmpty(paymentObserver.Messages); var notification = paymentObserver.Messages[0].Value; Assert.IsTrue(notification.HasValue); } else { Assert.IsEmpty(paymentObserver.Messages); } if (typeof(T) == typeof(MessageEvent)) { Assert.IsNotEmpty(messageObserver.Messages); var notification = messageObserver.Messages[0].Value; Assert.IsTrue(notification.HasValue); } else { Assert.IsEmpty(messageObserver.Messages); } }