Esempio n. 1
0
 public void SaveSingleColor()
 {
     byte[] savedBytes = BinaryDataExtensions.ToByteArray(Color.Red);
     Assert.AreEqual(4, savedBytes.Length);
     Assert.AreEqual(255, savedBytes[0]);
     Assert.AreEqual(0, savedBytes[1]);
     Assert.AreEqual(0, savedBytes[2]);
     Assert.AreEqual(255, savedBytes[3]);
 }
Esempio n. 2
0
 public void SaveMultipleColors()
 {
     byte[] savedBytes = BinaryDataExtensions.ToByteArray(new[] { Color.Red, Color.Green });
     Assert.AreEqual(8, savedBytes.Length);
     Assert.AreEqual(255, savedBytes[0]);
     Assert.AreEqual(0, savedBytes[1]);
     Assert.AreEqual(0, savedBytes[2]);
     Assert.AreEqual(255, savedBytes[3]);
     Assert.AreEqual(0, savedBytes[4]);
     Assert.AreEqual(255, savedBytes[5]);
     Assert.AreEqual(0, savedBytes[6]);
     Assert.AreEqual(255, savedBytes[7]);
 }
        public void ExpectExceptionForUnreadableData()
        {
            var message = new TestMessage {
                content = "This message cannot be resolved!", ID = 0
            };
            var memoryStream = new MemoryStream(new byte[64]);
            var binaryWriter = new BinaryWriter(memoryStream);

            binaryWriter.Write(BinaryDataExtensions.ToByteArray(message));
            memoryStream.Position = 0;
            var binaryReader = new BinaryReader(memoryStream);

            Assert.Throws <TypeLoadException>(() => binaryReader.Create());
        }
Esempio n. 4
0
 public void SetData(Vertex[] setVertices, short[] setIndices)
 {
     SetData(BinaryDataExtensions.ToByteArray(setVertices), setIndices);
 }