public void AddAccount_will_set_the_region_based_on_the_first_account_added()
        {
            var client = new Mock<IFlashRemotingClient>();
            var account = new LeagueAccount(client.Object, LeagueRegion.NorthAmerica, "testUser1", "testPassword1");
            var connection = new CompositeLeagueAccount()
                .AddAccount(account);

            Assert.That(connection, Is.Not.Null);
            Assert.That(connection.Region, Is.EqualTo(LeagueRegion.NorthAmerica));
        }
        public void AddAccount_throws_when_account_region_doesnt_match_connection_region()
        {
            var client = new Mock<IFlashRemotingClient>();
            var account = new LeagueAccount(client.Object, LeagueRegion.NorthAmerica, "testUser1", "testPassword1");
            var account2 = new LeagueAccount(client.Object, LeagueRegion.Brazil, "testUser2", "testPassword2");
            var connection = new CompositeLeagueAccount()
                .AddAccount(account);

            Assert.Throws<LeagueException>(() => connection.AddAccount(account2));
        }
        public void GetNextAccount_will_throw_when_no_connections_are_open()
        {
            var client1 = new Mock<IFlashRemotingClient>();
            client1.Setup(x => x.IsConnected).Returns(false);
            var client2 = new Mock<IFlashRemotingClient>();
            client2.Setup(x => x.IsConnected).Returns(false);

            var acct1 = new LeagueAccount(client1.Object, LeagueRegion.NorthAmerica, "testUser1", "testPassword1");
            var acct2 = new LeagueAccount(client2.Object, LeagueRegion.NorthAmerica, "testUser2", "testPassword2");
            var connection = new CompositeLeagueAccount()
                .AddAccount(acct1)
                .AddAccount(acct2);

            Assert.That(connection, Is.Not.Null);
            Assert.Throws<LeagueConnectionException>(() => connection.GetNextAccount());
        }
        public void GetNextAccount_will_cycle_through_connections_cyclicly()
        {
            var client1 = new Mock<IFlashRemotingClient>();
            client1.Setup(x => x.IsConnected).Returns(true);
            var client2 = new Mock<IFlashRemotingClient>();
            client2.Setup(x => x.IsConnected).Returns(true);
            var client3 = new Mock<IFlashRemotingClient>();
            client3.Setup(x => x.IsConnected).Returns(true);

            var acct1 = new LeagueAccount(client1.Object, LeagueRegion.NorthAmerica, "testUser1", "testPassword1");
            var acct2 = new LeagueAccount(client2.Object, LeagueRegion.NorthAmerica, "testUser2", "testPassword2");
            var acct3 = new LeagueAccount(client2.Object, LeagueRegion.NorthAmerica, "testUser3", "testPassword3");
            var connection = new CompositeLeagueAccount()
                .AddAccount(acct1)
                .AddAccount(acct2)
                .AddAccount(acct3);

            Assert.That(connection, Is.Not.Null);
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct2));
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct3));
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct1));
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct2));
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct3));
            Assert.That(connection.GetNextAccount(), Is.EqualTo(acct1));
        }