public void Inequivalence()
        {
            var sensor1 = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };
            var sensor2 = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xAA } } },
                SignalStrength = 0.1,
                SSID = "Rete1"
            };
            var sensor3 = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xAA } } },
                SignalStrength =4,
                SSID = "Rete1"
            };


            var left = new LocationSensorDatas() { SensorDatas = new List<SensorData>() { sensor1, sensor2 } };
            var right = new LocationSensorDatas() { SensorDatas = new List<SensorData>() { sensor1, sensor3 } };

            Assert.IsFalse(left.BusinessEquals(right));
            Assert.IsFalse(right.BusinessEquals(left));
            Assert.IsFalse(right.Equals(left));
        }
Пример #2
0
        public virtual bool BusinessEquals(WlanSensorData other, bool compareSignalStrength)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;

            return SSID.Equals(other.SSID) &&
                   BSSIDs.All((x)=> other.BSSIDs.Any(y=> x.BusinessEquals(y))) &&
                   (!compareSignalStrength || SignalStrength.Equals(other.SignalStrength));
        }
Пример #3
0
        public void InequivalenceWithoutSignal()
        {
            var left = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };
            var right = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xAA } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };

            Assert.IsFalse(left.BusinessEquals(right, false));
            Assert.IsFalse(right.BusinessEquals(left, false));
        }
        public void ShouldReturnZeroDistanceForSameLocation()
        {
            var sensor1 = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };
            var sensor2 = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xAA } } },
                SignalStrength = 0.1,
                SSID = "Rete1"
            };

            var left = new LocationSensorDatas() { SensorDatas = new List<SensorData>() { sensor1, sensor2 } };
            var right = new LocationSensorDatas() { SensorDatas = new List<SensorData>() { sensor1, sensor2 } };

            Assert.AreEqual(0d, left.DistanceFrom(right));
            Assert.AreEqual(0d, right.DistanceFrom(left));
        }
Пример #5
0
        public void ShouldReturnMaximumDistanceForADifferentSensor()
        {
            var left = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };

            var right = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xBB, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };

            Assert.AreEqual(left.SquaredDistanceFrom(right), 1d);
            Assert.AreEqual(right.SquaredDistanceFrom(left), 1d);
        }
Пример #6
0
        public void ShouldReturnCorrectDistanceForSameSensor()
        {
            var left = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 1,
                SSID = "Rete1"
            };

            var right = new WlanSensorData()
            {
                BSSIDs = new List<MacAddress>() { new MacAddress() { Bytes = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF } } },
                SignalStrength = 0.5,
                SSID = "Rete1"
            };

            var result = Math.Pow(1d - 0.5d, 2);

            Assert.AreEqual(left.SquaredDistanceFrom(right), result);
            Assert.AreEqual(right.SquaredDistanceFrom(left), result);
        }