public async void RetrieveStreamTest() { bool streamOffline = false; Stream stream = null; // This stream may be offline so it is suggested you edit // this line to get a stream that is online. stream = await twixel.RetrieveStream((await twixel.GetUserId("monstercat")).ToString()); if (stream != null) { Assert.Equal("Music", stream.game); } else { Assert.True(streamOffline); } TwixelException ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("ETdfdsfjldsjdfs")); Assert.IsType(typeof(TwixelException), ex); ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("22747608")); Assert.Equal("22747608 is offline", ex.Message); }
public async void UnblockUserTest() { User user = await twixel.RetrieveUserWithAccessToken(accessToken); List <Block> blockedUsers = await user.RetrieveBlockedUsers(); bool?unblockedUser = null; foreach (Block u in blockedUsers) { if (u.user.name == "nightblue3") { unblockedUser = await user.UnblockUser((await twixel.GetUserId("nightblue3")).ToString()); break; } } if (unblockedUser != null) { Assert.True(unblockedUser); } else { Assert.True(false); } TwixelException ex = await Assert.ThrowsAsync <TwixelException>(async() => await user.UnblockUser((await twixel.GetUserId("nightblue3")).ToString())); }
public async void RetrieveStreamTest() { bool streamOffline = false; Stream stream = null; // This stream may be offline so it is suggested you edit // this line to get a stream that is online. stream = await twixel.RetrieveStream("saltyteemo"); if (stream != null) { Assert.Equal("League of Legends", stream.game); } else { Assert.True(streamOffline); } TwixelException ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("ETdfdsfjldsjdfs")); Assert.IsType(typeof(TwitchException), ex.InnerException); Assert.Equal(404, ((TwitchException)ex.InnerException).Status); ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("golf1052")); Assert.Equal("golf1052 is offline", ex.Message); }
public static async Task ShowErrorDialog(TwixelException ex) { if (ex.Error != null) { await ShowMessageDialog(string.Format("Message: {0}\n\nError: {1}\n\nStatus Code: {2}", ex.Message, ex.Error.Error, ex.Error.Status.ToString())); } else { await ShowMessageDialog(string.Format("Message: {0}", ex.Message), ex.Message); } }