public void TestDetectsDaveMHardwareBeacon() { var bytes = HexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600050003be020e09526164426561636f6e20555342020a0300000000000000000000000000"); var parser = new AltBeaconParser(); var beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); Assert.NotNull(beacon, "Beacon should be not null if parsed successfully"); }
public void TestRecognizeBeacon() { var bytes = HexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c509"); var parser = new AltBeaconParser(); var beacon = parser.FromScanData(bytes, -55, null); Assert.AreEqual(9, ((AltBeacon)beacon).MfgReserved, "manData should be parsed"); }
public void TestParseWrongFormatReturnsNothing() { LogManager.D("XXX", "testParseWrongFormatReturnsNothing start"); var bytes = HexStringToByteArray("02011a1aff1801ffff2f234454cf6d4a0fadf2f4911ba9ffa600010002c509"); var parser = new AltBeaconParser(); var beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); LogManager.D("XXX", "testParseWrongFormatReturnsNothing end"); Assert.Null(beacon, "Beacon should be null if not parsed successfully"); }
public void TestDetectsAlternateBeconType() { var bytes = HexStringToByteArray("02011a1bff1801aabb2f234454cf6d4a0fadf2f4911ba9ffa600010002c50900"); var parser = new AltBeaconParser(); parser.SetMatchingBeaconTypeCode(new Java.Lang.Long(0xaabbL)); var beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); Assert.NotNull(beacon, "Beacon should be not null if parsed successfully"); }
public void TestRecognizeBeacon() { var beaconManager = BeaconManager.GetInstanceForApplication(Android.App.Application.Context); var bytes = HexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c50900"); AltBeaconParser parser = new AltBeaconParser(); Beacon beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); Assert.AreEqual(1, beacon.DataFields.Count, "Beacon should have one data field"); Assert.AreEqual(9, ((AltBeacon)beacon).MfgReserved, "manData should be parsed"); }
public void testSetBeacons() { StaticBeaconSimulator staticBeaconSimulator = new StaticBeaconSimulator(); byte[] beaconBytes = HexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c509"); Beacon beacon = new AltBeaconParser().FromScanData(beaconBytes, -55, null, DateTime.UtcNow.Ticks); List <Beacon> beacons = new List <Beacon>(); beacons.Add(beacon); staticBeaconSimulator.Beacons = beacons; AssertEx.AreEqual("getBeacons should match values entered with setBeacons", staticBeaconSimulator.Beacons, beacons); }
public void TestParsesBeaconMissingDataField() { var bytes = HexStringToByteArray("02011a1aff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c5000000"); var parser = new AltBeaconParser(); var beacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); Assert.AreEqual(-55, beacon.Rssi, "mRssi should be as passed in"); Assert.AreEqual("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6", beacon.GetIdentifier(0).ToString(), "uuid should be parsed"); Assert.AreEqual("1", beacon.GetIdentifier(1).ToString(), "id2 should be parsed"); Assert.AreEqual("2", beacon.GetIdentifier(2).ToString(), "id3 should be parsed"); Assert.AreEqual(-59, beacon.TxPower, "txPower should be parsed"); Assert.AreEqual(0x118, beacon.Manufacturer, "manufacturer should be parsed"); Assert.AreEqual(Convert.ToInt64(new Java.Lang.Long(0)), Convert.ToInt64(beacon.DataFields[0]), "missing data field zero should be zero"); }
public void testGetAltBeaconScanFilter() { BeaconParser parser = new AltBeaconParser(); BeaconManager.SetsManifestCheckingDisabled(true); // no manifest available in robolectric var scanFilterDatas = new ScanFilterUtils().CreateScanFilterDataForBeaconParser(parser); AssertEx.AreEqual("scanFilters should be of correct size", 1, scanFilterDatas.Count); ScanFilterUtils.ScanFilterData sfd = scanFilterDatas[0]; AssertEx.AreEqual("manufacturer should be right", 0x0118, sfd.Manufacturer); AssertEx.AreEqual("mask length should be right", 2, sfd.Mask.Count); AssertEx.AreEqual("mask should be right", new byte[] { (byte)0xff, (byte)0xff }, sfd.Mask); AssertEx.AreEqual("filter should be right", new byte[] { (byte)0xbe, (byte)0xac }, sfd.Filter); }