public void CanCallInitMultipleTimes() { using (var sut = new MixerRestClient(LoggerFactory, Client)) { sut.InitAsync(ChannelName, Token).Wait(Simulator.TIMEOUT); sut.InitAsync(ChannelName, null).Wait(Simulator.TIMEOUT); } }
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(); } }
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(); } }
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); } }
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); } }
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")); } }
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); } }
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); } }
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"); } }
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); } }
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); } }
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"); } }
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"); } }
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); } }