public void ReadNull() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); output.Write(null); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.IsNull(channel.Read()); }
public void ReadString() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); output.Write("foo"); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual("foo", channel.Read()); }
public void ReadByte() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); byte bt = 64; output.Write(bt); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(bt, channel.Read()); }
public void ReadCharacter() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); char ch = 'a'; output.Write(ch); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(ch, channel.Read()); }
public void ReadLongInteger() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); long ln = long.MaxValue; output.Write(ln); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(ln, channel.Read()); }
public void ReadShortInteger() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); short sh = short.MaxValue; output.Write(sh); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(sh, channel.Read()); }
public void ReadDecimal() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); decimal dc = 12.34m; output.Write(dc); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(dc, channel.Read()); }
public void WriteNull() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); channel.Write(null); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Null, reader.ReadByte()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteFloat() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); channel.Write((float)123.45); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Single, reader.ReadByte()); Assert.AreEqual((float)123.45, reader.ReadSingle()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteDecimal() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); decimal dc = 12.34m; channel.Write(dc); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Decimal, reader.ReadByte()); Assert.AreEqual(dc, reader.ReadDecimal()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteLongInteger() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); long ln = 123; channel.Write(ln); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Long, reader.ReadByte()); Assert.AreEqual(ln, reader.ReadInt64()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteShortInteger() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); short sh = 123; channel.Write(sh); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Short, reader.ReadByte()); Assert.AreEqual(sh, reader.ReadInt16()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void SendMessagesToActor() { int total = 0; EventWaitHandle wait = new AutoResetEvent(false); Actor actor = new LambdaActor(c => { total += (int)c; if (total >= 6) { wait.Set(); } }); ActorSystem system = new ActorSystem(); var server = new TcpServer("localhost", 3001, system); var result = system.ActorOf(actor, "myactor"); var path = result.Path.ToString(); server.Start(); var client = new System.Net.Sockets.TcpClient(); client.Connect("localhost", 3001); var channel = new OutputChannel(new System.IO.BinaryWriter(client.GetStream())); channel.Write(path); channel.Write(1); channel.Write(path); channel.Write(2); channel.Write(path); channel.Write(3); wait.WaitOne(); Assert.AreEqual(6, total); client.Close(); server.Stop(); system.Shutdown(); }