Exemplo n.º 1
0
        public void Assert_DataMapperProfile_ModelToDataObject_Works()
        {
            Mapper.Initialize(cfg => cfg.AddProfile(new DataMapperProfile()));

            Property property = new Property()
            {
                Name = "Property1",
                Address = "Address1",
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 200
            };

            Data.Models.Property propertyDataObject = new Data.Models.Property();

            Mapper.Map(property, propertyDataObject);

            propertyDataObject = Mapper.Map<Data.Models.Property>(property);

            Assert.AreEqual("Property1", propertyDataObject.Name);
            Assert.AreEqual("Address1", propertyDataObject.Address);
            Assert.AreEqual("LRE", propertyDataObject.AgencyCode);
            Assert.AreEqual(100, propertyDataObject.Latitude);
            Assert.AreEqual(200, propertyDataObject.Longitude);
        }
        private static bool CheckAgencyPropertyExists(Property agencyProperty, Data.Models.Property databasePropertyDto)
        {
            IPropertyMatcherFactory factory = new PropertyMatcherFactory();
            IPropertyMatcher propertyMatcher = factory.GetPropertyMatcher(agencyProperty.AgencyCode);

            return propertyMatcher.IsMatch(agencyProperty, Mapper.Map<Property>(databasePropertyDto));
        }
        private static List<Property> MapToPropertyList(PropertyListDeserializer properties)
        {
            List<Property> propertyList = new List<Property>();

            foreach (var property in properties.Properties)
            {
                PropertyFieldValidator.Validate(property);

                Property agencyProperty = new Property();

                Mapper.Map(property, agencyProperty);

                propertyList.Add(agencyProperty);
            }
            return propertyList;
        }
Exemplo n.º 4
0
        public void Test_GeoCodeMatcher_SameLatitude_LongitudeOutside200_Expect_Return_Matched()
        {
            Property agencyProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 105
            };

            Property databaseProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 107 // should be 222, outside 200, expect false
            };

            IPropertyMatcher propertyMatcher = new GeoCodeMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsFalse(isMatch);
        }
Exemplo n.º 5
0
        public void Test_GeoCodeMatcher_DifferentLatitudeLongiture_2degreedifference_Expect_Return_Matched()
        {
            Property agencyProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 100
            };

            Property databaseProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 102,
                Longitude = 102
            };

            // Distance should be squareroot (2 * 2 + 2 * 2) * 111 = 222km: outside 200km

            IPropertyMatcher propertyMatcher = new GeoCodeMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsFalse(isMatch);
        }
Exemplo n.º 6
0
        public void Test_GeoCodeMatcher_DifferentLatitudeLongiture_1degreedifference_Expect_Return_Matched()
        {
            Property agencyProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 100
            };

            Property databaseProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 101,
                Longitude = 101
            };

            // Distance should be squareroot (1 * 1 + 1 * 1) * 111 = 156km: within 200km

            IPropertyMatcher propertyMatcher = new GeoCodeMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsTrue(isMatch);
        }
Exemplo n.º 7
0
        public void Assert_XmlModelMapperProfile_Works()
        {
            Mapper.Initialize(cfg => cfg.AddProfile(new XmlModelMapperProfile()));

            PropertyDeserializer propertyDeserializer = new PropertyDeserializer
            {
                Name = "Property1",
                Address = "Address1",
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 200
            };

            Property property = new Property();

            Mapper.Map(propertyDeserializer, property);

            Assert.AreEqual("Property1", property.Name);
            Assert.AreEqual("Address1", property.Address);
            Assert.AreEqual("LRE", property.AgencyCode);
            Assert.AreEqual(100, property.Latitude);
            Assert.AreEqual(200, property.Longitude);
        }
Exemplo n.º 8
0
        public void Test_GeoCodeMatcher_SameLatitude_LongitudeWithin200_Expect_Return_Matched()
        {
            Property agencyProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 105
            };

            Property databaseProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 106 // should be 111, within 200
            };

            IPropertyMatcher propertyMatcher = new GeoCodeMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsTrue(isMatch);
        }
Exemplo n.º 9
0
        public void Test_ReverseNameMatch()
        {
            Property agencyProperty = new Property
            {
                Name = "Apartments Summit The",
            };

            Property databaseProperty = new Property
            {
                Name = "The Summit Apartments",
            };

            IPropertyMatcher propertyMatcher = new ReverseWordMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsTrue(isMatch);
        }
Exemplo n.º 10
0
        public void Test_NameAddressMatcher()
        {
            Property agencyProperty = new Property
            {
                Name = "*Super*-High! APARTMENTS (Sydney)",
                Address = "32 Sir John-Young Crescent, Sydney, NSW"
            };

            Property databaseProperty = new Property
            {
                Name = "Super High Apartments, Sydney",
                Address = "32 Sir John Young Crescent, Sydney NSW"
            };

            IPropertyMatcher propertyMatcher = new NameAddressMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsTrue(isMatch);
        }
Exemplo n.º 11
0
        public void Test_GeoCodeMatcher_SameLocation_SameAgencyCode_Expect_Return_Matched()
        {
            Property agencyProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 105
            };

            Property databaseProperty = new Property
            {
                AgencyCode = "LRE",
                Latitude = 100,
                Longitude = 105
            };

            IPropertyMatcher propertyMatcher = new GeoCodeMatcher();

            bool isMatch = propertyMatcher.IsMatch(agencyProperty, databaseProperty);

            Assert.IsTrue(isMatch);
        }