public void IsDataServicesEdmx_returns_false_for_no_data_services_edmx() { Assert.False( EdmUtils.IsDataServicesEdmx(XDocument.Parse("<Edmx xmlns=\"abc\"><DataServices /></Edmx>"))); Assert.False( EdmUtils.IsDataServicesEdmx( XDocument.Parse("<Edmx xmlns=\"http://schemas.microsoft.com/ado/2009/11/edmx\" />"))); }
public void IsDataServicesEdmx_returns_true_for_known_data_services_edmx() { const string edmxTemplate = "<Edmx xmlns=\"{0}\"><DataServices /></Edmx>"; foreach (var edmxNs in SchemaManager.GetEDMXNamespaceNames()) { Assert.True( EdmUtils.IsDataServicesEdmx( XDocument.Parse( string.Format(edmxTemplate, edmxNs)))); } }
internal static void SqlCeUpgradeService_OnUpgradeProject(IVsHierarchy hierarchy, IVsUpgradeLogger logger) { if (PackageManager.Package != null && PackageManager.Package.ModelManager != null) { // since this is about retargeting EDMX files on disk, no need to process other file extensions from any converters var fileFinder = new VSFileFinder(EntityDesignArtifact.ExtensionEdmx); fileFinder.FindInProject(hierarchy); var project = VSHelpers.GetProject(hierarchy); // skip the step if it is a miscellaneous project. if (project != null && !VsUtils.IsMiscellaneousProject(project)) { IDictionary <string, object> documentMap = new Dictionary <string, object>(); foreach (var vsFileInfo in fileFinder.MatchingFiles) { try { var projectItem = VsUtils.GetProjectItem(hierarchy, vsFileInfo.ItemId); // Dev 10 bug 648969: skip the process for astoria edmx file. if (EdmUtils.IsDataServicesEdmx(projectItem.get_FileNames(1))) { continue; } // Check whether project item is a linked item var isLinkItem = VsUtils.IsLinkProjectItem(projectItem); if (!isLinkItem) { var doc = MetadataConverterDriver.SqlCeInstance.Convert(SafeLoadXmlFromPath(vsFileInfo.Path)); if (doc != null) { documentMap.Add(vsFileInfo.Path, doc); } } } catch (Exception ex) { var errMsg = String.Format( CultureInfo.CurrentCulture, Resources.ErrorDuringSqlCeUpgrade, vsFileInfo.Path, ex.Message); logger.LogMessage((uint)__VSUL_ERRORLEVEL.VSUL_ERROR, project.Name, vsFileInfo.Path, errMsg); return; } } if (documentMap.Count > 0) { VsUtils.WriteCheckoutXmlFilesInProject(documentMap); } // now update the config file as needed var configFileUtils = new ConfigFileUtils(project, PackageManager.Package); try { var configXmlDoc = configFileUtils.LoadConfig(); if (configXmlDoc != null) // check config file exists { if (ConnectionManager.UpdateSqlCeProviderInConnectionStrings(configXmlDoc)) { configFileUtils.SaveConfig(configXmlDoc); } } } catch (Exception ex) { var errMsg = String.Format( CultureInfo.CurrentCulture, Resources.ErrorDuringSqlCeUpgrade, configFileUtils.GetConfigPath(), ex.Message); logger.LogMessage((uint)__VSUL_ERRORLEVEL.VSUL_ERROR, project.Name, configFileUtils.GetConfigPath(), errMsg); } } } }
public void IsDataServicesEdmx_returns_false_for_invalid_Xml_file() { Assert.False(EdmUtils.IsDataServicesEdmx(GetType().Assembly.Location)); }
public void IsDataServicesEdmx_returns_false_for_invalid_or_non_existing_path() { Assert.False(EdmUtils.IsDataServicesEdmx((string)null)); Assert.False(EdmUtils.IsDataServicesEdmx(string.Empty)); Assert.False(EdmUtils.IsDataServicesEdmx(Guid.NewGuid().ToString())); }
// protected virtual to allow mocking protected virtual bool IsDataServicesEdmx(string filePath) { Debug.Assert(!string.IsNullOrWhiteSpace(filePath), "Invalid filePath"); return(EdmUtils.IsDataServicesEdmx(filePath)); }