/// <summary> /// returns ture if the chain code is the same and the supplierHotel is within 200 metres or less of the actual hotel location. /// /// Assumption: 1 degree of latitude or longitude is equal to 111km /// Assumption: case Sensitive when comparing chain code /// </summary> public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel) { bool isChainCodeEqual = string.Compare(supplierHotel.ChainCode, hotel.ChainCode, false) == 0 ? true : false; double distanceApartInMeter = LocationHelpers.DistanceBetweenPlaces(supplierHotel.Longitude, supplierHotel.Latitude, hotel.Longitude, hotel.Latitude); bool locationSatisfy = distanceApartInMeter <= 200 ? true : false; return (isChainCodeEqual && locationSatisfy); }
/// <summary> /// Returns true if Both hotel's name and Address match when punctuation is excluded /// /// Assumption: Space will be removed when comparing /// Assumption: case insensitive when comparing /// </summary> /// <param name="supplierHotel"></param> /// <param name="hotel"></param> /// <returns></returns> public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel) { var pureSName = NameHelpers.RemovePunctuationAndSpaceInAString(supplierHotel.Name); var pureSAddress = NameHelpers.RemovePunctuationAndSpaceInAString(supplierHotel.Address); var pureName = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Name); var pureAddress = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Address); int nameCompare = string.Compare(pureSName, pureName, true); int addressCompare = string.Compare(pureSAddress, pureAddress, true); return (Math.Abs(nameCompare) + Math.Abs(addressCompare)) == 0; }
public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel) { //reverse var reversedSName = NameHelpers.ReverseWordInASentence(supplierHotel.Name); //remove punctuation var pureSName = NameHelpers.RemovePunctuationAndSpaceInAString(reversedSName); var pureName = NameHelpers.RemovePunctuationAndSpaceInAString(hotel.Name); var match = string.Compare(pureSName, pureName, true) == 0 ? true : false; return match; }
public void ContraryCountryGetawaysMatcher_IsMatch_Name() { var matcher = new ContraryCountryGetawaysMatcher(); var supplierHotel = new SupplierHotel() { Name = "Manor Country Mayhew’s Ralph Lord" }; var hotel = new Hotel() { Name = "Lord Ralph Mayhew’s Country Manor" }; var isMatch = matcher.IsMatch(supplierHotel, hotel); Assert.AreEqual(true, isMatch); }
public void SuperfluousHotelMatcher_NotMatch_Name() { var matcher = new SuperfluousHotelMatcher(); var supplierHotel = new SupplierHotel() { Address = "22 Carrington-Square, Dubbo, NSW.", Name = "*Good*-Times! HOTEL (Dubbo)" }; var hotel = new Hotel() { Address = "22 Carrington Square, Dubbo NSW", Name = "Good Times Hotel, Dubbo, AFEGGDFA" }; var isMatch = matcher.IsMatch(supplierHotel, hotel); Assert.AreEqual(false, isMatch); }
public void ThereaboutsHolidaysMatcher_NotMatch_ChainCode_Distance() { var matcher = new ThereaboutsHolidaysMatcher(); var supplierHotel = new SupplierHotel() { ChainCode = "UH", Latitude = 38.001M, Longitude = -77.001M }; var hotel = new Hotel() { ChainCode = "HH", Latitude = 39.002M, Longitude = -77.002M }; var isMatch = matcher.IsMatch(supplierHotel, hotel); Assert.AreEqual(false, isMatch); }
/// <summary> /// Compare the supplierHotel and hotel by using a MatcherClassName using reflection /// </summary> /// <param name="supplierHotel"></param> /// <param name="hotel"></param> /// <param name="matcherClassName"></param> /// <returns></returns> public static bool IsMatch(SupplierHotel supplierHotel, Hotel hotel, string matcherClassName) { return GetMatcherByName(matcherClassName).IsMatch(supplierHotel, hotel); }