public void ReadRegistry_Upgrade_ExistingVersion1()
        {
            string         dataLocation = Path.Combine("mock:", "registryDataFolder");
            MockFileSystem fileSystem   = new MockFileSystem(new MockDirectory(dataLocation, null, null));

            string repo1 = Path.Combine("mock:", "code", "repo1");
            string repo2 = Path.Combine("mock:", "code", "repo2");

            // Create a version 1 registry file
            fileSystem.WriteAllText(
                Path.Combine(dataLocation, RepoRegistry.RegistryName),
                $@"1
{{""EnlistmentRoot"":""{repo1.Replace("\\", "\\\\")}"",""IsActive"":false}}
{{""EnlistmentRoot"":""{repo2.Replace("\\", "\\\\")}"",""IsActive"":true}}
");

            RepoRegistry registry = new RepoRegistry(
                new MockTracer(),
                fileSystem,
                dataLocation,
                this.mockRepoMounter.Object,
                this.mockNotificationHandler.Object);

            registry.Upgrade();

            Dictionary <string, RepoRegistration> repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(2);

            this.VerifyRepo(repos[repo1], expectedOwnerSID: null, expectedIsActive: false);
            this.VerifyRepo(repos[repo2], expectedOwnerSID: null, expectedIsActive: true);
        }
Esempio n. 2
0
        public void ReadRegistry_Upgrade_NoRegistry()
        {
            string         dataLocation = Path.Combine("mock:", "registryDataFolder");
            MockFileSystem fileSystem   = new MockFileSystem(new MockDirectory(dataLocation, null, null));
            RepoRegistry   registry     = new RepoRegistry(new MockTracer(), fileSystem, dataLocation, this.mockRepoMounter.Object);

            registry.Upgrade();

            Dictionary <string, RepoRegistration> repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(0);
        }
Esempio n. 3
0
        public void ReadRegistry_Upgrade_NoRegistry()
        {
            string         dataLocation = @"mock:\registryDataFolder";
            MockFileSystem fileSystem   = new MockFileSystem(new MockDirectory(dataLocation, null, null));
            RepoRegistry   registry     = new RepoRegistry(new MockTracer(), fileSystem, dataLocation);

            registry.Upgrade();

            Dictionary <string, RepoRegistration> repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(0);
        }
Esempio n. 4
0
        public void ReadRegistry_Upgrade_NoRegistry()
        {
            string dataLocation = Path.Combine(GetTestWorkingDir(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(dataLocation);

            RepoRegistry registry = new RepoRegistry(new MockTracer(), dataLocation);

            registry.Upgrade();

            var repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(0);
        }
Esempio n. 5
0
        public void ReadRegistry_Upgrade_ExistingVersion1()
        {
            /*
             * {"EnlistmentRoot":"c:\\code\\repo1","IsActive":false}
             * {"EnlistmentRoot":"c:\\code\\repo2","IsActive":true}
             */

            string dataLocation = Path.Combine(GetTestWorkingDir(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(dataLocation);
            File.Copy(GetDataPath("Version1Registry"), Path.Combine(dataLocation, RepoRegistry.RegistryName));

            RepoRegistry registry = new RepoRegistry(new MockTracer(), dataLocation);

            registry.Upgrade();

            var repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(2);

            this.VerifyRepo(repos["c:\\code\\repo1"], expectedOwnerSID: null, expectedIsActive: false);
            this.VerifyRepo(repos["c:\\code\\repo2"], expectedOwnerSID: null, expectedIsActive: true);
        }
Esempio n. 6
0
        public void ReadRegistry_Upgrade_ExistingVersion1()
        {
            string         dataLocation = @"mock:\registryDataFolder";
            MockFileSystem fileSystem   = new MockFileSystem(new MockDirectory(dataLocation, null, null));

            // Create a version 1 registry file
            fileSystem.WriteAllText(
                Path.Combine(dataLocation, RepoRegistry.RegistryName),
                @"1
{""EnlistmentRoot"":""c:\\code\\repo1"",""IsActive"":false}
{""EnlistmentRoot"":""c:\\code\\repo2"",""IsActive"":true}
");

            RepoRegistry registry = new RepoRegistry(new MockTracer(), fileSystem, dataLocation);

            registry.Upgrade();

            Dictionary <string, RepoRegistration> repos = registry.ReadRegistry();

            repos.Count.ShouldEqual(2);

            this.VerifyRepo(repos["c:\\code\\repo1"], expectedOwnerSID: null, expectedIsActive: false);
            this.VerifyRepo(repos["c:\\code\\repo2"], expectedOwnerSID: null, expectedIsActive: true);
        }