Example #1
0
 public void CanCallInitMultipleTimes()
 {
     using (var sut = new MixerRestClient(LoggerFactory, Client))
     {
         sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);
         sut.InitAsync(ChannelName, null).Wait(Simulator.TIMEOUT);
     }
 }
Example #2
0
        public void LookupUserReturnNullIdUnknownUser()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var userId = sut.LookupUserIdAsync("InvalidUserNameForSure").Result;
                userId.Should().BeNull();
            }
        }
Example #3
0
        public void HandlesUnknownGameTypeById()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var gameType = sut.LookupGameTypeByIdAsync(34634).Result;

                // Assert
                gameType.Should().BeNull();
            }
        }
Example #4
0
        public void CanLookupUserId()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var r = sut.LookupUserIdAsync(OtherUserName).Result;

                // Assert
                r.Should().Be(OtherUserId);
            }
        }
Example #5
0
        public void CanInit()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                // Assert
                Handler.RequestHistory.Count.Should().Be(2);
                sut.UserId.Should().Be(UserId);
                sut.UserName.Should().Be(UserName);
            }
        }
Example #6
0
        public void CheckAcceptsHeader()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                // Assert
                var req = Handler.FindRequest($"channels/{WebUtility.UrlEncode(ChannelName)}");
                req.Should().NotBeNull();
                req.Method.Should().Be(HttpMethod.Get);
                req.Headers.Should().Contain(new KeyValuePair <string, string>("Accept", "application/json"));
            }
        }
Example #7
0
        public void CanGetChannelInfo()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var(title, gameTypeId) = sut.GetChannelInfoAsync().Result;

                // Assert
                title.Should().Be("Test stream title 1");
                gameTypeId.Should().Be(GameTypeId);
            }
        }
Example #8
0
        public void ParsesStreamStartAndRoundsCorrectly()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var r = sut.GetStreamStartedAtAsync().Result;

                // Assert
                r.Should().NotBeNull();
                r.Value.Should().Be(StartedAtTestValue);
            }
        }
Example #9
0
        public void CanLookupGameTypeById()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var gameType = sut.LookupGameTypeByIdAsync(GameTypeId).Result;

                // Assert
                gameType.Should().NotBeNull();
                gameType.Id.Should().Be(GameTypeId);
                gameType.Name.Should().Be("TestGameName");
            }
        }
Example #10
0
        public void ChatAuthRequest()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var result = sut.GetChatAuthKeyAndEndpointsAsync().Result;

                // Assert
                result.Should().NotBeNull();
                result.Authkey.Should().Be(SimAuth.Value.ChatAuthKey);
                result.Endpoints.Should().BeEquivalentTo(Endpoints);
            }
        }
Example #11
0
        public void WillRetryInit()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client)
            {
                RetryDelay = 0, MaxTries = 5
            })
            {
                Action call = () => sut.InitAsync("InvalidChannelName", Token).Wait(Simulator.TIMEOUT);

                // Assert
                call.Should().Throw <MixerException>();
                Handler.RequestHistory.Count.Should().Be(5);
            }
        }
Example #12
0
        public void CanLookupGameTypeByQuery()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var gameTypes = sut.LookupGameTypeAsync("GameName").Result;

                // Assert
                gameTypes.Should().NotBeNull();
                gameTypes.Should().ContainSingle();
                gameTypes.First().Id.Should().Be(GameTypeId);
                gameTypes.First().Name.Should().Be("GameName");
            }
        }
Example #13
0
        public void CanUnbanUser()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                var result = sut.UnbanUserAsync(OtherUserName).Result;

                // Assert
                var req = Handler.FindRequest($"channels/{ChannelId}/users/{OtherUserId}", new HttpMethod("PATCH"));
                req.Should().NotBeNull();
                req.Content.Should().NotBeNullOrWhiteSpace();

                var doc = JToken.Parse(req.Content);
                doc["remove"].Should().NotBeNull();
                doc["remove"].Values <string>().Should().Contain("Banned");
            }
        }
Example #14
0
        public void CanUpdateGetChannelInfo()
        {
            using (var sut = new MixerRestClient(LoggerFactory, Client))
            {
                sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT);

                sut.UpdateChannelInfoAsync("New stream title", GameTypeId).Wait();

                var req = Handler.FindRequest($"channels/{ChannelId}", new HttpMethod("PATCH"));
                req.Should().NotBeNull();
                req.Content.Should().NotBeNullOrWhiteSpace();

                var doc = JToken.Parse(req.Content);
                doc["name"].Should().NotBeNull();
                doc["name"].Value <string>().Should().Be("New stream title");
                doc["typeId"].Should().NotBeNull();
                doc["typeId"].Value <uint>().Should().Be(GameTypeId);
            }
        }