//TODO: Implement ISerializable public void TestCanSerialize() { var beacon = new AltBeacon.Builder().SetId1("1").SetId2("2").SetId3("3").SetRssi(4) .SetBeaconTypeCode(5).SetTxPower(6).SetBluetoothName("xx") .SetBluetoothAddress("1:2:3:4:5:6").SetDataFields(new List <Java.Lang.Long> { new Java.Lang.Long(100L) }).Build(); byte[] serializedBeacon = ConvertToBytes(beacon); Beacon beacon2 = (Beacon)ConvertFromBytes(serializedBeacon); AssertEx.AreEqual("Right number of identifiers after deserialization", 3, beacon2.Identifiers.Count); AssertEx.AreEqual("id1 is same after deserialization", beacon.GetIdentifier(0), beacon2.GetIdentifier(0)); AssertEx.AreEqual("id2 is same after deserialization", beacon.GetIdentifier(1), beacon2.GetIdentifier(1)); AssertEx.AreEqual("id3 is same after deserialization", beacon.GetIdentifier(2), beacon2.GetIdentifier(2)); AssertEx.AreEqual("txPower is same after deserialization", beacon.TxPower, beacon2.TxPower); AssertEx.AreEqual("rssi is same after deserialization", beacon.Rssi, beacon2.Rssi); AssertEx.AreEqual("distance is same after deserialization", beacon.Distance, beacon2.Distance, 0.001); AssertEx.AreEqual("bluetoothAddress is same after deserialization", beacon.BluetoothAddress, beacon2.BluetoothAddress); AssertEx.AreEqual("bluetoothAddress is same after deserialization", beacon.BluetoothName, beacon2.BluetoothName); AssertEx.AreEqual("beaconTypeCode is same after deserialization", beacon.BeaconTypeCode, beacon2.BeaconTypeCode); AssertEx.AreEqual("manufacturer is same after deserialization", beacon.Manufacturer, beacon2.Manufacturer); AssertEx.AreEqual("data field 0 is the same after deserialization", beacon.DataFields[0], beacon2.DataFields[0]); AssertEx.AreEqual("data field 0 is the right value", beacon.DataFields[0], new Java.Lang.Long(100L)); }
public void TestAccessBeaconIdentifiers() { Beacon beacon = new AltBeacon.Builder().SetMfgReserved(7).SetId1("1").SetId2("2").SetId3("3").SetRssi(4) .SetBeaconTypeCode(5).SetTxPower(6) .SetBluetoothAddress("1:2:3:4:5:6").Build(); AssertEx.AreEqual("First beacon id should be 1", beacon.GetIdentifier(0).ToString(), "1"); AssertEx.AreEqual("Second beacon id should be 1", beacon.GetIdentifier(1).ToString(), "2"); AssertEx.AreEqual("Third beacon id should be 1", beacon.GetIdentifier(2).ToString(), "3"); AssertEx.AreEqual("First beacon id should be 1", beacon.Id1.ToString(), "1"); AssertEx.AreEqual("Second beacon id should be 1", beacon.Id2.ToString(), "2"); AssertEx.AreEqual("Third beacon id should be 1", beacon.Id3.ToString(), "3"); }