Beispiel #1
0
        public async Task ShoutOut_will_use_custom_message_if_there_is_one()
        {
            // arrange
            var userProfile = new TwitcherProfile {
                ShoutMessage = "hey hey look at me" + Guid.NewGuid()
            };
            var userName             = "******";
            var expectedShoutMessage = userProfile.ShoutMessage + $" https://twitch.tv/{userName}";
            var twitchLibMessage     = TwitchLibMessageBuilder.Create()
                                       .WithUsername("doesntmatter")
                                       .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithIsSubscriber(true)
                              .WithMessage($"!so {userName}")
                              .Build();

            MockApiWrapper.Setup(x => x.DoesUserExist(userName)).ReturnsAsync(true);
            MockCollection.Setup(x => x.ExistsAsync(userName.ToLower(), null))
            .ReturnsAsync(new FakeExistsResult(true));
            MockCollection.Setup(x => x.GetAsync(userName.ToLower(), null))
            .ReturnsAsync(new FakeGetResult(userProfile));
            var shout = new ShoutOut(chatMessage);

            // act
            await _handler.Handle(shout, CancellationToken.None);

            // assert
            MockTwitchClient.Verify(x => x.SendMessage(It.IsAny <string>(), expectedShoutMessage, false), Times.Once);
        }
Beispiel #2
0
 public void Map(TwitcherProfile twitcherProfile, string twitchUsername)
 {
     TwitchUsername = twitchUsername;
     ShoutMessage   = twitcherProfile.ShoutMessage;
     FanfareEnabled = twitcherProfile.HasFanfare ?? false;
     if (twitcherProfile.Fanfare != null)
     {
         FanfareMessage          = twitcherProfile.Fanfare.Message;
         FanfareTimeout          = twitcherProfile.Fanfare.Timeout;
         FanfareYouTubeCode      = twitcherProfile.Fanfare.YouTubeCode;
         FanfareYouTubeEndTime   = twitcherProfile.Fanfare.YouTubeEndTime;
         FanfareYouTubeStartTime = twitcherProfile.Fanfare.YouTubeStartTime;
     }
 }
Beispiel #3
0
        public async Task <Unit> Handle(UpdateProfile request, CancellationToken cancellationToken)
        {
            var profile = new TwitcherProfile();

            profile.Fanfare = new FanfareInfo();

            profile.ShoutMessage             = request.ShoutMessage;
            profile.HasFanfare               = request.FanfareEnabled;
            profile.Fanfare.Message          = request.FanfareMessage;
            profile.Fanfare.Timeout          = request.FanfareTimeout;
            profile.Fanfare.YouTubeStartTime = request.FanfareYouTubeStartTime;
            profile.Fanfare.YouTubeEndTime   = request.FanfareYouTubeEndTime;
            profile.Fanfare.YouTubeCode      = request.FanfareYouTubeCode;

            await _bucket.UpsertAsync(request.TwitchUsername, profile);

            return(default);