상속: IValueReader
예제 #1
0
        public void SerializeDeserialize()
        {
            const string logo = "logo";
            const string name = "name";
            const string desc = "description";

            ServerInfo info = new ServerInfo (new ServerSettings
            {
                ServerLogo = logo,
                Name = name,
                Description = desc,
                ServerPassword = "******"
            }, new GuestUserProvider());

            var stream = new MemoryStream (new byte[20480], true);
            var writer = new StreamValueWriter (stream);
            var reader = new StreamValueReader (stream);

            info.Serialize (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            info = new ServerInfo (null, reader);
            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (logo, info.Logo);
            Assert.AreEqual (name, info.Name);
            Assert.AreEqual (desc, info.Description);
            Assert.AreEqual (true, info.Passworded);
            Assert.AreEqual (UserRegistrationMode.None, info.RegistrationMode);
            Assert.IsNull (info.RegistrationContent);
        }
예제 #2
0
        public void SerializeDeserialize()
        {
            var stream = new MemoryStream (new byte[20480], true);
            var writer = new StreamValueWriter (stream);
            var reader = new StreamValueReader (stream);

            var source = GetTestSource();
            source.Serialize (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            source = new AudioSource (null, reader);
            AssertSourcesMatch (GetTestSource(), source);
            Assert.AreEqual (length, stream.Position);
        }
예제 #3
0
        public void SerializeDeserialize()
        {
            var stream = new MemoryStream (new byte[20480], true);
            var writer = new StreamValueWriter (stream);
            var reader = new StreamValueReader (stream);

            var channel = new ChannelInfo (1)
            {
                ParentChannelId = 2,
                Name = "Name",
                Description = "Description",
                ReadOnly = false,
                UserLimit = 2
            };

            channel.Serialize (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            var deserializedChannel = new ChannelInfo();
            deserializedChannel.Deserialize (null, reader);

            Assert.AreEqual (length, stream.Position);
            AssertChanelsAreEqual (channel, deserializedChannel);
        }
예제 #4
0
        public void SerializeDeserialize()
        {
            var stream = new MemoryStream(new byte[20480], true);
            var writer = new StreamValueWriter (stream);
            var reader = new StreamValueReader (stream);

            var info = new UserInfo (Nickname, Phonetic, Username, UserId, ChanId, Muted, Comment, Status);

            info.Serialize (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            info = new UserInfo (null, reader);
            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (UserId, info.UserId);
            Assert.AreEqual (ChanId, info.CurrentChannelId);
            Assert.AreEqual (Nickname, info.Nickname);
            Assert.AreEqual (Phonetic, info.Phonetic);
            Assert.AreEqual (Muted, info.IsMuted);
            Assert.AreEqual (Comment, info.Comment);
            Assert.AreEqual (Status, info.Status);
        }
예제 #5
0
        public void SerializeDeserialize()
        {
            var stream = new MemoryStream(new byte[20480], true);
            var writer = new StreamValueWriter (stream);
            var reader = new StreamValueReader (stream);

            var args = new AudioCodecArgs (Format, Bitrate, FrameSize, Complexity);

            args.Serialize (null, writer);
            long length = stream.Position;
            stream.Position = 0;

            args = new AudioCodecArgs (null, reader);
            Assert.AreEqual (length, stream.Position);
            Assert.AreEqual (Format.WaveEncoding, args.WaveEncoding);
            Assert.AreEqual (Format.Channels, args.Channels);
            Assert.AreEqual (Format.BitsPerSample, args.BitsPerSample);
            Assert.AreEqual (Bitrate, args.Bitrate);
            Assert.AreEqual (Format.SampleRate, args.SampleRate);
            Assert.AreEqual (FrameSize, args.FrameSize);
            Assert.AreEqual (Complexity, args.Complexity);
        }