コード例 #1
0
        public void RequestUpdatedSourceList()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.RequestSource);
            var audioArgs = AudioCodecArgsTests.GetTestArgs();

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

            var result = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result.SourceResult);

            handler.RequestSourceListMessage(new MessageEventArgs <RequestSourceListMessage> (server, new RequestSourceListMessage()));
            var list = client.DequeueAndAssertMessage <SourceListMessage>();

            Assert.AreEqual(1, list.Sources.Count());
            Assert.Contains(result.Source, list.Sources.ToList());
            client.AssertNoMessage();

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

            var result2 = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result2.SourceResult);

            handler.RequestSourceListMessage(new MessageEventArgs <RequestSourceListMessage> (server, new RequestSourceListMessage()));
            list = client.DequeueAndAssertMessage <SourceListMessage>();

            Assert.AreEqual(2, list.Sources.Count());
            Assert.Contains(result.Source, list.Sources.ToList());
            Assert.Contains(result2.Source, list.Sources.ToList());
            client.AssertNoMessage();
        }
コード例 #2
0
        public void RequestSourceListFromViewer()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.RequestSource);
            var audioArgs = AudioCodecArgsTests.GetTestArgs();

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

            var result = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result.SourceResult);

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

            var result2 = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result2.SourceResult);
            client.AssertNoMessage();

            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));

            handler.RequestSourceListMessage(new MessageEventArgs <RequestSourceListMessage> (c, new RequestSourceListMessage()));
            var list = cl.DequeueAndAssertMessage <SourceListMessage>();

            Assert.AreEqual(2, list.Sources.Count());
            Assert.Contains(result.Source, list.Sources.ToList());
            Assert.Contains(result2.Source, list.Sources.ToList());
            cl.AssertNoMessage();
        }
コード例 #3
0
        public void CreateFake()
        {
            string      name      = "fakeMonkeys";
            AudioFormat format    = AudioFormat.Stereo16bitLPCM;
            short       frameSize = 480;

            var s = this.handler.CreateFake(name, format, frameSize);

            Assert.AreEqual(name, s.Name);
            AudioCodecArgsTests.AssertAreEqual(new AudioCodecArgs(format, 0, frameSize, 10), s.CodecSettings);

            Assert.AreSame(s, this.handler[s.Id]);
        }
コード例 #4
0
        public void SourceStateChangeSameChannel()
        {
            var c = Connect();
            var u = Join(false, c, Nickname);

            c.SendAsync(new RequestSourceMessage("source", AudioCodecArgsTests.GetTestArgs()));
            c.DequeueAndAssertMessage <SourceResultMessage>();

            c.SendAsync(new ClientAudioSourceStateChangeMessage {
                Starting = true, SourceId = 1
            });

            //var msg = c.Client.DequeueAndAssertMessage<AudioSourceStateChangeMessage>();
            //Assert.AreEqual (true, msg.Starting);
            //Assert.AreEqual (1, msg.SourceId);
        }
コード例 #5
0
        public void RequestSource()
        {
            var c = Connect();
            var u = Join(false, c, Nickname);

            var args = AudioCodecArgsTests.GetTestArgs();

            c.SendAsync(new RequestSourceMessage("source", args));

            var msg = c.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, msg.SourceResult);
            Assert.AreEqual("source", msg.Source.Name);
            Assert.AreEqual(false, msg.Source.IsMuted);
            AudioCodecArgsTests.AssertAreEqual(args, msg.Source.CodecSettings);
        }
コード例 #6
0
        public void RequestSourceDuplicateSourceName()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.RequestSource);

            var audioArgs = AudioCodecArgsTests.GetTestArgs();

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

            var result = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result.SourceResult);

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

            result = client.DequeueAndAssertMessage <SourceResultMessage>();
            Assert.AreEqual(SourceResult.FailedDuplicateSourceName, result.SourceResult);
        }
コード例 #7
0
        public void RequestSourceBelowMinBitrate()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.RequestSource);

            var audioArgs = new AudioCodecArgs(AudioFormat.Mono16bitLPCM, 1, AudioSourceTests.FrameSize, 10);

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

            var result = client.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result.SourceResult);
            Assert.AreEqual("Name", result.SourceName);
            Assert.AreEqual("Name", result.Source.Name);

            audioArgs.Bitrate = minBitrate;
            AudioCodecArgsTests.AssertAreEqual(audioArgs, result.Source.CodecSettings);

            client.AssertNoMessage();
        }
コード例 #8
0
        public void SourceResult()
        {
            const string name   = "Name";
            var          result = Messages.SourceResult.Succeeded;
            var          source = new AudioSource(name, 1, 2, AudioCodecArgsTests.GetTestArgs());
            var          msg    = new SourceResultMessage(name, result, source);

            Assert.AreEqual(result, msg.SourceResult);
            Assert.AreEqual(name, msg.SourceName);
            msg.WritePayload(serverContext, writer);
            long length = stream.Position;

            stream.Position = 0;

            msg = new SourceResultMessage();
            msg.ReadPayload(clientContext, reader);
            Assert.AreEqual(length, stream.Position);
            Assert.AreEqual(result, msg.SourceResult);
            Assert.AreEqual(name, msg.SourceName);
        }
コード例 #9
0
ファイル: ClientMessageTests.cs プロジェクト: ermau/Gablarski
        public void RequestSource()
        {
            const string name       = "Voice";
            const int    bitrate    = 64000;
            const short  frameSize  = 480;
            const byte   complexity = 10;

            var args = AudioCodecArgsTests.GetTestArgs();
            var msg  = new RequestSourceMessage(name, args);

            Assert.AreEqual(name, msg.Name);
            msg.WritePayload(null, writer);
            long length = stream.Position;

            stream.Position = 0;

            msg = new RequestSourceMessage();
            msg.ReadPayload(null, reader);
            Assert.AreEqual(length, stream.Position);
            Assert.AreEqual(name, msg.Name);
        }
コード例 #10
0
        public AudioSource GetSourceFromRequest(MockServerConnection serverConnection, ConnectionBuffer clientConnection)
        {
            permissions.EnablePermissions(userManager.GetUser(serverConnection).UserId, PermissionName.RequestSource);

            var audioArgs = new AudioCodecArgs(AudioFormat.Mono16bitLPCM, 64000, AudioSourceTests.FrameSize, 10);

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

            var result = clientConnection.DequeueAndAssertMessage <SourceResultMessage>();

            Assert.AreEqual(SourceResult.Succeeded, result.SourceResult);
            Assert.AreEqual("Name", result.SourceName);
            Assert.AreEqual("Name", result.Source.Name);

            AudioCodecArgsTests.AssertAreEqual(audioArgs, result.Source.CodecSettings);

            clientConnection.AssertNoMessage();

            return(result.Source);
        }
コード例 #11
0
        public void SourcesRemoved()
        {
            var sources = new List <AudioSource>
            {
                new AudioSource("voice", 1, UserId, AudioCodecArgsTests.GetTestArgs()),
                new AudioSource("voice", 2, UserId2, AudioCodecArgsTests.GetTestArgs())
            };

            var msg = new SourcesRemovedMessage(sources);

            Assert.AreEqual(1, msg.SourceIds.Count(sid => sid == sources[0].Id));
            Assert.AreEqual(1, msg.SourceIds.Count(sid => sid == sources[1].Id));
            msg.WritePayload(serverContext, writer);
            long length = stream.Position;

            stream.Position = 0;

            msg = new SourcesRemovedMessage();
            msg.ReadPayload(clientContext, reader);
            Assert.AreEqual(length, stream.Position);
            Assert.AreEqual(1, msg.SourceIds.Count(sid => sid == sources[0].Id));
            Assert.AreEqual(1, msg.SourceIds.Count(sid => sid == sources[1].Id));
        }
コード例 #12
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();
        }
コード例 #13
0
 public void SourceResultInvalid()
 {
     Assert.Throws <ArgumentNullException> (() => new SourceResultMessage(null, Messages.SourceResult.Succeeded, new AudioSource("name", 1, 2, AudioCodecArgsTests.GetTestArgs())));
     Assert.Throws <ArgumentNullException> (() => new SourceResultMessage("name", Messages.SourceResult.Succeeded, null));
     Assert.Throws <ArgumentNullException> (() => new SourceResultMessage("name", Messages.SourceResult.SourceRemoved, null));
     Assert.Throws <ArgumentNullException> (() => new SourceResultMessage("name", Messages.SourceResult.NewSource, null));
     Assert.DoesNotThrow(() => new SourceResultMessage("name", Messages.SourceResult.FailedLimit, null));
 }
コード例 #14
0
        public void RequestSourceNotJoined()
        {
            var cs = this.provider.GetConnections(GablarskiProtocol.Instance);
            var cl = new ConnectionBuffer(cs.Item1);

            userManager.Connect(cs.Item2);

            handler.RequestSourceMessage(new MessageEventArgs <RequestSourceMessage> (cs.Item2,
                                                                                      new RequestSourceMessage("Name", AudioCodecArgsTests.GetTestArgs())));

            cl.AssertNoMessage();
        }