コード例 #1
0
 public void GetChannelForUser()
 {
     this.TestWrapper(async(MixerClient client) =>
     {
         ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(client);
     });
 }
コード例 #2
0
        public void UpdateUserRoles()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                UserModel user = await connection.Users.GetUser("ChannelOne");

                Assert.IsNotNull(user);

                bool result = await connection.Channels.UpdateUserRoles(channel, user, new List <string>()
                {
                    "Mod"
                }, null);

                Assert.IsTrue(result);

                IEnumerable <UserWithGroupsModel> userRoles = await connection.Channels.GetUsersWithRoles(channel, "Mod");

                Assert.IsNotNull(userRoles);
                Assert.IsTrue(userRoles.Any(ug => ug.username.Equals("ChannelOne")));

                result = await connection.Channels.UpdateUserRoles(channel, user, null, new List <string>()
                {
                    "Mod"
                });

                Assert.IsTrue(result);

                userRoles = await connection.Channels.GetUsersWithRoles(channel, "Mod");

                Assert.IsNotNull(userRoles);
                Assert.IsFalse(userRoles.Any(ug => ug.username.Equals("ChannelOne")));
            });
        }
コード例 #3
0
        public void CreateGetUpdateDeleteGame()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                InteractiveGameListingModel gameListing = await InteractiveServiceUnitTests.CreateTestGame(connection, channel);

                IEnumerable <InteractiveGameListingModel> games = await connection.Interactive.GetOwnedInteractiveGames(channel);

                Assert.IsNotNull(games);
                Assert.IsTrue(games.Count() > 0);
                Assert.IsTrue(games.Any(g => g.id.Equals(gameListing.id)));

                string gameName           = gameListing.name = "Test Game";
                InteractiveGameModel game = await connection.Interactive.UpdateInteractiveGame(gameListing);

                Assert.IsNotNull(game);
                Assert.IsTrue(game.id > 0);
                Assert.AreEqual(game.name, gameName);

                await InteractiveServiceUnitTests.DeleteTestGame(connection, game);

                games = await connection.Interactive.GetOwnedInteractiveGames(channel);

                Assert.IsNotNull(games);
                Assert.IsFalse(games.Any(g => g.id.Equals(game.id)));
            });
        }
コード例 #4
0
        public void GetPreferences()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                ChannelPreferencesModel preference = await connection.Channels.GetPreferences(channel);

                Assert.IsNotNull(preference);

                preference.linksClickable = !preference.linksClickable;

                ChannelPreferencesModel newPreferences = await connection.Channels.UpdatePreferences(channel, preference);

                Assert.IsNotNull(newPreferences);
                Assert.AreEqual(preference.linksClickable, newPreferences.linksClickable);

                preference.linksClickable = !preference.linksClickable;

                newPreferences = await connection.Channels.UpdatePreferences(channel, preference);

                Assert.IsNotNull(newPreferences);
                Assert.AreEqual(preference.linksClickable, newPreferences.linksClickable);
            });
        }
コード例 #5
0
 public void GetChannelForUser()
 {
     TestWrapper(async(MixerConnection connection) =>
     {
         ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);
     });
 }
コード例 #6
0
        public void GetUpdateDiscord()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                DiscordBotModel discord = await connection.Channels.GetDiscord(channel);

                Assert.IsNotNull(discord);
                Assert.IsTrue(discord.id > 0);

                IEnumerable <DiscordChannelModel> channels = await connection.Channels.GetDiscordChannels(channel);

                Assert.IsNotNull(channels);
                Assert.IsTrue(channels.Count() > 0);

                IEnumerable <DiscordRoleModel> roles = await connection.Channels.GetDiscordRoles(channel);

                Assert.IsNotNull(roles);
                Assert.IsTrue(roles.Count() > 0);

                discord = await connection.Channels.UpdateDiscord(channel, discord);

                Assert.IsNotNull(discord);
                Assert.IsTrue(discord.id > 0);
            });
        }
コード例 #7
0
        public static void ClassInitialize(TestContext context)
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                testGameListing = await InteractiveServiceUnitTests.CreateTestGame(connection, channel);
            });
        }
コード例 #8
0
        public static async Task <ChannelChatModel> GetChat(MixerClient client)
        {
            ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(client);

            ChannelChatModel chat = await client.Chats.GetChat(channel);

            Assert.IsNotNull(chat);
            Assert.IsTrue(chat.endpoints.Count() > 0);

            return(chat);
        }
コード例 #9
0
        public void GetHosters()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <ChannelAdvancedModel> hosters = await connection.Channels.GetHosters(channel, 1);

                Assert.IsNotNull(hosters);
            });
        }
コード例 #10
0
        public void GetSharedInteractiveGames()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <InteractiveGameListingModel> games = await connection.Interactive.GetSharedInteractiveGames(channel);

                Assert.IsNotNull(games);
            });
        }
コード例 #11
0
        public static async Task <UserModel> GetCurrentUser(MixerClient client)
        {
            ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(client);

            PrivatePopulatedUserModel user = await client.Users.GetCurrentUser();

            Assert.IsNotNull(user);
            Assert.IsTrue(user.id > (uint)0);

            return(user);
        }
コード例 #12
0
        public void GetAllTimeSparksLeaderboard()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <SparksLeaderboardModel> leaderboard = await connection.Leaderboards.GetAllTimeSparksLeaderboard(channel);
                Assert.IsNotNull(leaderboard);
                Assert.IsTrue(leaderboard.Count() >= 0);
            });
        }
コード例 #13
0
        public static void ClassInitialize(TestContext context)
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);
                chatClient           = await ChatClient.CreateFromChannel(connection, channel);

                Assert.IsTrue(await chatClient.Connect());
                Assert.IsTrue(await chatClient.Authenticate());
            });
        }
コード例 #14
0
        public void GetHosters()
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(client);

                IEnumerable <ChannelAdvancedModel> hosters = await client.Channels.GetHosters(channel);

                Assert.IsNotNull(hosters);
            });
        }
コード例 #15
0
        public void GetUsers()
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(client);

                IEnumerable <ChatUserModel> users = await client.Chats.GetUsers(channel);

                Assert.IsNotNull(users);
                Assert.IsTrue(users.Count() > 0);
            });
        }
コード例 #16
0
        public void GetFollowers()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <UserWithChannelModel> users = await connection.Channels.GetFollowers(channel, 1);

                Assert.IsNotNull(users);
                Assert.IsTrue(users.Count() > 0);
            });
        }
コード例 #17
0
        public void GetSubscriberAnalytics()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <SubscriberAnalyticModel> subscribers = await connection.Channels.GetSubscriberAnalytics(channel, DateTimeOffset.Now.Subtract(TimeSpan.FromDays(7)));

                Assert.IsNotNull(subscribers);
                Assert.IsTrue(subscribers.Count() > 0);
            });
        }
コード例 #18
0
        public static void ClassInitialize(TestContext context)
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                testGameListing = await InteractiveServiceUnitTests.CreateTestGame(connection, channel);

                interactiveClient = await InteractiveClient.CreateFromChannel(connection, channel, testGameListing);

                Assert.IsTrue(await interactiveClient.Connect());
                Assert.IsTrue(await interactiveClient.Ready());
            });
        }
コード例 #19
0
        public void UpdateChannel()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                string newName = "Test Name";
                channel.name   = newName;

                channel = await connection.Channels.UpdateChannel(channel);

                Assert.IsNotNull(channel);
                Assert.IsTrue(string.Equals(channel.name, newName));
            });
        }
コード例 #20
0
        public void GetChannelEmoticons()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);
                UserModel user       = await connection.Users.GetCurrentUser();

                Assert.IsNotNull(user);
                Assert.IsTrue(user.id > (uint)0);

                IEnumerable <EmoticonPackModel> emoticonPacks = await connection.Channels.GetEmoticons(channel, user);

                Assert.IsNotNull(emoticonPacks);
            });
        }
コード例 #21
0
        public void GetChannelBroadcast()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                Assert.IsNotNull(channel);
                Assert.IsTrue(channel.id > (uint)0);

                BroadcastModel broadcast = await connection.Channels.GetCurrentBroadcast(channel);

                Assert.IsNotNull(broadcast);
                Assert.AreEqual(channel.id, broadcast.channelId);
            });
        }
コード例 #22
0
        public void GetChannelRecordings()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                Assert.IsNotNull(channel);
                Assert.IsTrue(channel.id > (uint)0);

                IEnumerable <ChannelRecordingModel> recordings = await connection.Channels.GetRecordings(channel);

                Assert.IsNotNull(recordings);
                Assert.IsTrue(recordings.Count() > 0);
            });
        }
コード例 #23
0
        public void LiveSubscribeAndUnsubscribe()
        {
            this.ConstellationWrapper(async(MixerConnection connection, ConstellationClient constellationClient) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                this.ClearPackets();

                ConstellationEventType eventType = new ConstellationEventType(ConstellationEventTypeEnum.channel__id__update, channel.id);
                Assert.IsTrue(await constellationClient.SubscribeToEventsWithResponse(new List <ConstellationEventType>()
                {
                    eventType
                }));

                this.ClearPackets();

                bool eventReceived = false;
                constellationClient.OnSubscribedEventOccurred += (sender, le) =>
                {
                    if (le.channel.Equals(eventType.ToString()))
                    {
                        eventReceived = true;
                    }
                };

                string newName = "Test Name - " + DateTimeOffset.Now;
                channel.name   = newName;

                channel = await connection.Channels.UpdateChannel(channel);

                Assert.IsNotNull(channel);
                Assert.IsTrue(string.Equals(channel.name, newName));

                this.ClearPackets();

                await Task.Delay(5000);

                if (!eventReceived)
                {
                    Assert.Fail("Did not get live event for channel updating");
                }

                Assert.IsTrue(await constellationClient.UnsubscribeToEventsWithResponse(new List <ConstellationEventType>()
                {
                    eventType
                }));
            });
        }
コード例 #24
0
        public void GetInteractiveVersion()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <InteractiveGameListingModel> games = await connection.Interactive.GetOwnedInteractiveGames(channel);

                Assert.IsNotNull(games);
                Assert.IsTrue(games.Count() > 0);

                InteractiveGameVersionModel version = await connection.Interactive.GetInteractiveGameVersion(games.First().versions.First());

                Assert.IsNotNull(version);
            });
        }
コード例 #25
0
        public void GetUsers()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <ChatUserModel> users = await connection.Chats.GetUsers(channel);

                Assert.IsNotNull(users);

                if (users.Count() > 0)
                {
                    ChatUserModel user = await connection.Chats.GetUser(channel, users.First().userId.GetValueOrDefault());
                }
            });
        }
コード例 #26
0
        public void GetUserFanProgression()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <UserWithGroupsModel> users = await connection.Channels.GetUsersWithRoles(channel, 1);

                Assert.IsNotNull(users);
                Assert.IsTrue(users.Count() > 0);

                UserFanProgressionModel userFanProgression = await connection.Channels.GetUserFanProgression(channel, users.First());

                Assert.IsNotNull(userFanProgression);
                Assert.AreEqual(userFanProgression.userId, users.First().id);
            });
        }
コード例 #27
0
        public void CheckGetDiscordInvite()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                UserModel user = await connection.Users.GetCurrentUser();

                bool result = await connection.Channels.CanUserGetDiscordInvite(channel, user);

                Assert.IsTrue(result);

                string invite = await connection.Channels.GetUserDiscordInvite(channel, user);

                Assert.IsNotNull(invite);
                Assert.IsTrue(invite.Length > 0);
            });
        }
コード例 #28
0
        public void CheckIfUsersHaveRole()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                UserModel modUser    = await connection.Users.GetUser("SXTBot");
                UserModel notModUser = await connection.Users.GetUser("ChannelOne");

                Dictionary <uint, DateTimeOffset?> usersWithRole = await connection.Channels.CheckIfUsersHaveRole(channel, new List <UserModel>()
                {
                    modUser, notModUser
                }, "Mod");
                Assert.IsNotNull(usersWithRole);
                Assert.IsTrue(usersWithRole.Count == 1);
                Assert.IsNotNull(usersWithRole.ContainsKey(modUser.id));
            });
        }
コード例 #29
0
        private void ChatWrapper(Func <MixerClient, ChatClient, Task> function)
        {
            this.TestWrapper(async(MixerClient client) =>
            {
                ChannelModel channel  = await ChannelsServiceUnitTests.GetChannel(client);
                ChatClient chatClient = await ChatClient.CreateFromChannel(client, channel);

                chatClient.ReplyOccurred      += ChatClient_ReplyOccurred;
                chatClient.EventOccurred      += ChatClient_EventOccurred;
                chatClient.DisconnectOccurred += ChatClient_DisconnectOccurred;

                chatClient.MessageOccurred += ChatClient_MessageOccurred;

                Assert.IsTrue(await chatClient.Connect());

                await function(client, chatClient);

                await chatClient.Disconnect();
            });
        }
コード例 #30
0
        public void UpdateChannelGame()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                string gameName = "Fortnite";
                IEnumerable <GameTypeSimpleModel> games = await connection.GameTypes.GetGameTypes(gameName);

                Assert.IsNotNull(games);
                Assert.IsTrue(games.Count() > 0);
                Assert.IsTrue(games.Any(gt => gt.name.Equals(gameName)));

                channel.typeId = games.First().id;

                channel = await connection.Channels.UpdateChannel(channel);

                Assert.IsNotNull(channel);
                Assert.IsTrue(channel.typeId == games.First().id);
            });
        }