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