public void FakeStatusNDescTest() { ConnectionMock mc = new ConnectionMock(); sHGG mockGG = new sHGG(mc); // available mockGG.GGStatus = GGStatusType.Available; Assert.AreEqual(mc.data.Length, 12); Assert.AreEqual(mc.ReadUInt(), 0x2); // type Assert.AreEqual(mc.ReadUInt(), 4); // size Assert.AreEqual(mc.ReadUInt(), 0x2); // status mc.ClearData(); // busy mockGG.GGStatus = GGStatusType.Busy; Assert.AreEqual(mc.data.Length, 12); Assert.AreEqual(mc.ReadUInt(), 0x2); // type Assert.AreEqual(mc.ReadUInt(), 4); // size Assert.AreEqual(mc.ReadUInt(), 0x3); // status mc.ClearData(); // + desc string desc = "abcdefghijk lmno"; mockGG.GGDescription = desc; Assert.AreEqual(mc.ReadUInt(), 0x2); // type Assert.AreEqual(mc.ReadUInt(), 4 + 1 + desc.Length); // size Assert.AreEqual(mc.ReadUInt(), 0x5); // status Assert.AreEqual(mc.ReadByte(), Convert.ToByte('a')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('b')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('c')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('d')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('e')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('f')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('g')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('h')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('i')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('j')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('k')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte(' ')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('l')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('m')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('n')); Assert.AreEqual(mc.ReadByte(), Convert.ToByte('o')); Assert.AreEqual(mc.ReadByte(), 0); Assert.IsTrue(mc.IsEnd); }
public void FullMockTest() { ConnectionMock mock = new ConnectionMock(); Assert.IsNotNull(mock); Assert.IsNotNull(mock.data); Assert.AreEqual(mock.data.Length, 0); byte[] pack1 = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; mock.Write(pack1); Assert.AreEqual(mock.data.Length, 7); Assert.AreEqual(mock.data[0], 1); Assert.AreEqual(mock.data[3], 4); Assert.AreEqual(mock.data[6], 7); byte[] pack2 = new byte[] { 9, 8, 7, 6, 5 }; mock.Write(pack2); Assert.AreEqual(mock.data.Length, 12); Assert.AreEqual(mock.data[0], 1); Assert.AreEqual(mock.data[6], 7); Assert.AreEqual(mock.data[7], 9); Assert.AreEqual(mock.data[11], 5); byte[] pack3 = new byte[] { 0, 1, 2, 3 }; mock.Write(pack3, 0, 2); Assert.AreEqual(mock.data.Length, 14); Assert.AreEqual(mock.data[0], 1); Assert.AreEqual(mock.data[6], 7); Assert.AreEqual(mock.data[7], 9); Assert.AreEqual(mock.data[11], 5); Assert.AreEqual(mock.data[12], 0); Assert.AreEqual(mock.data[13], 1); mock.ClearData(); Assert.IsNotNull(mock.data); Assert.AreEqual(mock.data.Length, 0); byte[] pack4 = new byte[] { 1, 2, 3, 4, 5 }; mock.Write(pack4, 0, 1); Assert.AreEqual(mock.data.Length, 1); Assert.AreEqual(mock.data[0], 1); mock.ClearData(); Assert.IsNotNull(mock.data); Assert.AreEqual(mock.data.Length, 0); }