Пример #1
0
        public void Setup()
        {
            permissions = new MockPermissionsProvider();
            users       = new MockUserProvider();

            provider = new MockConnectionProvider(GablarskiProtocol.Instance);

            context = new MockServerContext(provider)
            {
                Settings            = new ServerSettings(),
                UserProvider        = users,
                PermissionsProvider = permissions,
                ChannelsProvider    = new LobbyChannelProvider(),
            };

            context.Sources     = new ServerSourceHandler(context, new ServerSourceManager(context));
            context.Channels    = new ServerChannelHandler(context);
            context.UserManager = new ServerUserManager();
            context.Users       = handler = new ServerUserHandler(context, context.UserManager);

            context.Start();

            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            server = new ServerConnectionBuffer(cs.Item2);
            client = new ConnectionBuffer(cs.Item1);

            var observers = provider.GetConnections(GablarskiProtocol.Instance);

            sobserver = observers.Item2;
            observer  = new ConnectionBuffer(observers.Item1);
        }
Пример #2
0
        public async Task RequestChannelListMessageNotConnected()
        {
            var cs = provider.GetConnections(GablarskiProtocol.Instance);
            var c  = new ConnectionBuffer(cs.Item1);

            await c.DisconnectAsync();

            handler.RequestChanneListMessage(new MessageEventArgs <RequestChannelListMessage> (cs.Item2,
                                                                                               new RequestChannelListMessage()));

            c.AssertNoMessage();
        }
Пример #3
0
        public void Setup()
        {
            manager     = new ServerUserManager();
            permissions = new MockPermissionsProvider();
            channels    = new LobbyChannelProvider();

            MockServerContext mcontext;

            context = mcontext = new MockServerContext
            {
                ChannelsProvider    = channels,
                PermissionsProvider = permissions,
                UserManager         = new ServerUserManager(),
                Settings            = new ServerSettings {
                    Name = "Test Server"
                }
            };

            mcontext.Users    = new ServerUserHandler(context, manager);
            mcontext.Channels = handler = new ServerChannelHandler(context);

            user = UserInfoTests.GetTestUser(1, 1, false);

            provider = new MockConnectionProvider(GablarskiProtocol.Instance);
            mcontext.AddConnectionProvider(provider);
            mcontext.Start();

            var connections = provider.GetConnections(GablarskiProtocol.Instance);

            client = new ConnectionBuffer(connections.Item1);
            server = connections.Item2;

            manager.Connect(server);
            manager.Join(server, user);
        }
Пример #4
0
        public void Setup()
        {
            user    = new UserInfo("Nickname", "Phonetic", "Username", 1, 2, true);
            manager = new ServerUserManager();

            provider = new MockConnectionProvider(GablarskiProtocol.Instance);
            provider.Start(MessageTypes.All);

            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            server = cs.Item2;
            client = cs.Item1;
        }
Пример #5
0
        public void Setup()
        {
            permissions = new MockPermissionsProvider();

            LobbyChannelProvider channels = new LobbyChannelProvider();

            channels.SaveChannel(new ChannelInfo
            {
                Name = "Channel 2"
            });

            this.provider = new MockConnectionProvider(GablarskiProtocol.Instance);
            this.provider.Start(MessageTypes.All);

            userManager = new ServerUserManager();
            MockServerContext c;

            context = c = new MockServerContext(provider)
            {
                Settings = new ServerSettings
                {
                    Name = "Server",
                    DefaultAudioBitrate = defaultBitrate,
                    MaximumAudioBitrate = maxBitrate,
                    MinimumAudioBitrate = minBitrate
                },

                UserManager         = userManager,
                PermissionsProvider = permissions,
                ChannelsProvider    = channels
            };
            c.Users = new ServerUserHandler(context, userManager);

            manager = new ServerSourceManager(context);
            handler = new ServerSourceHandler(context, manager);

            user = UserInfoTests.GetTestUser(1, 1, false);

            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            client = new ConnectionBuffer(cs.Item1);
            server = cs.Item2;

            userManager.Connect(server);
            userManager.Join(server, user);
        }
Пример #6
0
        private ConnectionBuffer Connect()
        {
            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            var connection = new ConnectionBuffer(cs.Item1);

            connection.SendAsync(new ConnectMessage {
                ProtocolVersion = GablarskiProtocol.Instance.Version, Host = "test", Port = 42912
            });
            connection.DequeueAndAssertMessage <ServerInfoMessage>();
            connection.DequeueAndAssertMessage <ChannelListMessage>();
            connection.DequeueAndAssertMessage <UserInfoListMessage>();
            connection.DequeueAndAssertMessage <SourceListMessage>();
            return(connection);
        }
Пример #7
0
        public void LoginResult()
        {
            LoginResultState state = LoginResultState.Success;
            var msg = new LoginResultMessage(new LoginResult(UserId, state));

            Assert.IsTrue(msg.Result.Succeeded);
            Assert.AreEqual(state, msg.Result.ResultState);
            Assert.AreEqual(UserId, msg.Result.UserId);

            var provider = new MockConnectionProvider(GablarskiProtocol.Instance);

            provider.Start(MessageTypes.All);

            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            this.clientContext = new SerializationContext(cs.Item1, new Dictionary <byte, Protocol> {
                { 42, GablarskiProtocol.Instance }
            });
            this.serverContext = new SerializationContext(cs.Item2, new Dictionary <byte, Protocol> {
                { 42, GablarskiProtocol.Instance }
            });
        }
Пример #8
0
        public void RequestSourceNotification()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.RequestSource);

            var cs = provider.GetConnections(GablarskiProtocol.Instance);
            var c  = cs.Item2;
            var cl = new ConnectionBuffer(cs.Item1);

            userManager.Connect(c);
            userManager.Join(c, UserInfoTests.GetTestUser(2));

            var audioArgs = AudioCodecArgsTests.GetTestArgs();

            handler.RequestSourceMessage(new MessageEventArgs <RequestSourceMessage> (server,
                                                                                      new RequestSourceMessage("Name", audioArgs)));

            var sourceAdded = cl.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.NewSource, sourceAdded.SourceResult);
            Assert.AreEqual("Name", sourceAdded.SourceName);
            AudioCodecArgsTests.AssertAreEqual(audioArgs, sourceAdded.Source.CodecSettings);

            cl.AssertNoMessage();
        }
Пример #9
0
        public void JoinAsGuestAlreadyJoined()
        {
            var cs = provider.GetConnections(GablarskiProtocol.Instance);

            JoinAsGuest(server, client, true, true, null, "Nickname", null);
            JoinAsGuest(new ConnectionBuffer(cs.Item2), new ConnectionBuffer(cs.Item1), false, false, true, null, "Nickname", null);
        }