Beispiel #1
0
        public void TestMigration()
        {
            // Create 1.3, and 2.0 version user data directories in Temp folder
            string userDataDir;

            CreateMockDirectoriesAndFiles(out userDataDir);

            var sourceVersionDir = Path.Combine(userDataDir, "1.3");
            var settingsFilePath = Path.Combine(sourceVersionDir, "DynamoSettings.xml");

            // Create PreferenceSettings.xml file in 1.3
            CreateMockPreferenceSettingsFile(settingsFilePath, sourceVersionDir);

            // Create mock objects for IPathManager and IPathResolver
            var mockPathManager = new Mock <IPathManager>();

            var currentVersionDir = Path.Combine(userDataDir, "2.0");

            mockPathManager.Setup(x => x.UserDataDirectory).Returns(() => currentVersionDir);

            // Test MigrateBetweenDynamoVersions
            var targetMigrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(
                mockPathManager.Object);

            // Assert that new CustomePackageFolders in preference settings
            // for 2.0 version points to user data dir for 2.0
            Assert.AreEqual(currentVersionDir,
                            targetMigrator.PreferenceSettings.CustomPackageFolders[0]);
        }
Beispiel #2
0
        public void TestSelectedDownloadPathIsNotMigrated()
        {
            // Create 1.3, and 2.0 version user data directories in Temp folder
            string userDataDir;

            CreateMockDirectoriesAndFiles(out userDataDir);

            var sourceVersionDir = Path.Combine(userDataDir, "1.3");
            var settingsFilePath = Path.Combine(sourceVersionDir, "DynamoSettings.xml");

            // Create PreferenceSettings.xml file in 1.3
            CreateMockPreferenceSettingsFile(settingsFilePath, sourceVersionDir);

            // Create mock objects for IPathManager and IPathResolver
            var mockPathManager = new Mock <IPathManager>();

            var currentVersionDir = Path.Combine(userDataDir, "2.0");

            mockPathManager.Setup(x => x.UserDataDirectory).Returns(() => currentVersionDir);


            // Test MigrateBetweenDynamoVersions
            var targetMigrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(
                mockPathManager.Object);

            var sourcePrefs = PreferenceSettings.Load(settingsFilePath);

            Assert.AreEqual(sourceVersionDir, sourcePrefs.SelectedPackagePathForInstall);

            // Assert that new SelectedPackagePath is not equal to the old path.
            Assert.AreNotEqual(sourcePrefs.SelectedPackagePathForInstall,
                               targetMigrator.PreferenceSettings.SelectedPackagePathForInstall);
        }
Beispiel #3
0
        public void TestMigration()
        {
            // Create 0.8, and 0.9 version user data directories in Temp folder
            string userDataDir;

            CreateMockDirectoriesAndFiles(out userDataDir);

            var sourceVersionDir = Path.Combine(userDataDir, "0.8");
            var settingsFilePath = Path.Combine(sourceVersionDir, "DynamoSettings.xml");

            // Create PreferenceSettings.xml file in 0.8
            CreateMockPreferenceSettingsFile(settingsFilePath, sourceVersionDir);

            // Create mock objects for IPathManager and IPathResolver
            var mockPathManager  = new Mock <IPathManager>();
            var mockPathResolver = new Mock <IPathResolver>();

            var currentVersionDir = Path.Combine(userDataDir, "0.9");

            mockPathResolver.Setup(x => x.UserDataRootFolder).Returns(() => userDataDir);
            mockPathManager.Setup(x => x.UserDataDirectory).Returns(() => currentVersionDir);

            // Test MigrateBetweenDynamoVersions
            var targetMigrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(
                mockPathManager.Object, mockPathResolver.Object);

            // Assert that both 0.8 and 0.9 dirs are the same after migration
            var sourcePackageDir  = Path.Combine(sourceVersionDir, "packages");
            var currentPackageDir = Path.Combine(currentVersionDir, "packages");

            bool areDirectoriesEqual = Directory.EnumerateFiles(sourcePackageDir).Select(Path.GetFileName).
                                       SequenceEqual(Directory.EnumerateFiles(currentPackageDir).Select(Path.GetFileName));

            Assert.IsTrue(areDirectoriesEqual);

            var sourceDefinitionDir  = Path.Combine(sourceVersionDir, "definitions");
            var currentDefinitionDir = Path.Combine(currentVersionDir, "definitions");

            areDirectoriesEqual = Directory.EnumerateFiles(sourceDefinitionDir).Select(Path.GetFileName).
                                  SequenceEqual(Directory.EnumerateFiles(currentDefinitionDir).Select(Path.GetFileName));
            Assert.IsTrue(areDirectoriesEqual);

            // Assert that new CustomePackageFolders in preference settings
            // for 0.9 version points to user data dir for 0.9
            Assert.AreEqual(currentVersionDir,
                            targetMigrator.PreferenceSettings.CustomPackageFolders[0]);
        }