public void AddCompareListsToDB() { RestaurantsCompareList compList = new RestaurantsCompareList(); OpenStreetMapServices osm = new OpenStreetMapServices(); //act string id = osm.AddRestaurantsCompareListToImportedDB(compList); //assert Assert.IsNotNull(id); }
/// <summary> /// Compare all existing OSM restaurants in ImportedRestaurantsDB with all RestaurantBasicData in main DB /// in CompareList in ImportedRestaurantsDB /// </summary> public RestaurantsCompareList CompareAllOsmRestaurantsWithDB() { log.InfoFormat("[CompareAllOsmRestaurantsWithDB]."); int hasSimilarCount = 0; int noSimilarCount = 0; int notSimilarWithNearest = 0; int notSimilarWithoutNearest = 0; OpenStreetMapServices osmServices = new OpenStreetMapServices(); RestaurantsCompareList compareList = FindSimilarRestaurants(); if (compareList != null) { foreach (var restList in compareList.CompareList) { if (restList.HasSimilarRest) { hasSimilarCount++; string similarRest = (restList.SimilarRests != null && restList.SimilarRests[restList.IndexOfSimilarRest] != null) ? restList.SimilarRests[restList.IndexOfSimilarRest].ToString() : "uknown"; if (similarRest != "uknown") restList.OsmRest.ReferenceId = restList.SimilarRests[restList.IndexOfSimilarRest].Id; log.InfoFormat("[CompareAllOsmRestaurantsWithDB] HasSimilarRest=True: RestaurantOSM={0}, RestaurantBasicData={1}.", restList.OsmRest.ToString(), similarRest); } else //HasSimilarRest = false { noSimilarCount++; List<string> restsNames = new List<string>(); if (restList.SimilarRests.Count > 0) { notSimilarWithNearest++; foreach (var rest in restList.SimilarRests) { restsNames.Add("Rest.Name=" + rest.Name + ", Rest.Id=" + rest.Id.ToString()); } } else notSimilarWithoutNearest++; log.InfoFormat("[CompareAllOsmRestaurantsWithDB] HasSimilarRest=False: RestaurantOSM={0}, NearestRestsList={1}.", restList.OsmRest.ToString(), restsNames.ToString()); } } log.InfoFormat("[CompareAllOsmRestaurantsWithDB] after log loop, hasSimilarCount={0}, noSimilarCount={1}, notSimilarWithNearest={2}, notSimilarWithoutNearest={3}.", hasSimilarCount, noSimilarCount, notSimilarWithNearest, notSimilarWithoutNearest); osmServices.AddRestaurantsCompareListToImportedDB(compareList); return compareList; } else log.InfoFormat("[CompareAllOsmRestaurantsWithDB] CompareList is null.)"); return null; }