public void TestRemoteSource_Acquire()
        {
            RemoteTemplatesSource rts = new RemoteTemplatesSource();

            rts.LoadConfig();
            var package = rts.Config.Latest;

            rts.Acquire(ref package);

            string acquiredContentFolder = package.LocalPath;

            Assert.NotNull(acquiredContentFolder);

            // Ensure package is not downloaded again if already downloaded
            rts.Acquire(ref package);
            Assert.True(acquiredContentFolder == package.LocalPath);

            // Reset localPath and ensure it is acquired again
            if (Directory.Exists(Path.GetDirectoryName(package.LocalPath)))
            {
                Directory.Delete(Path.GetDirectoryName(package.LocalPath), true);
            }

            rts.Acquire(ref package);

            Assert.True(package.LocalPath != acquiredContentFolder);

            if (Directory.Exists(Path.GetDirectoryName(package.LocalPath)))
            {
                Directory.Delete(Path.GetDirectoryName(package.LocalPath), true);
            }
        }
        public void TestRemoteSource()
        {
            // Bug #333
            // Location will give access to temp location.
            // code base won't if they are on diff drives
            //
            // If someone has a temp dir that is different than their extention
            // move will fail, you need to copy / delete
            // string drive = Path.GetPathRoot(Assembly.GetExecutingAssembly().Location);
            string drive        = Path.GetPathRoot(new Uri(typeof(TemplatePackageTests).Assembly.CodeBase).LocalPath);
            string targetFolder = Path.Combine(drive, @"Temp\TestRts");

            try
            {
                RemoteTemplatesSource rts = new RemoteTemplatesSource();
                rts.Acquire(targetFolder);

                string acquiredContentFolder = Directory.EnumerateDirectories(targetFolder).FirstOrDefault();

                Assert.NotNull(acquiredContentFolder);

                // There is just one
                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 1);

                // Ensure even downloaded, if there is coincident content, it is not duplicated.
                rts.Acquire(targetFolder);
                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 1);

                // Change the previous acquired content and ensure it is acquired again
                Directory.Move(acquiredContentFolder, acquiredContentFolder + "_old");

                rts.Acquire(targetFolder);

                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 2);
            }
            finally
            {
                if (Directory.Exists(targetFolder))
                {
                    Directory.Delete(targetFolder, true);
                }
            }
        }
예제 #3
0
        public void TestRemoteSource()
        {
            string drive        = Path.GetPathRoot(new Uri(typeof(TemplatePackageTests).Assembly.CodeBase).LocalPath);
            string targetFolder = Path.Combine(drive, $@"Temp\TestRts{Process.GetCurrentProcess().Id}_{Thread.CurrentThread.ManagedThreadId}");

            try
            {
                RemoteTemplatesSource rts = new RemoteTemplatesSource();
                rts.Acquire(targetFolder);

                string acquiredContentFolder = Directory.EnumerateDirectories(targetFolder).FirstOrDefault();

                Assert.NotNull(acquiredContentFolder);

                // There is just one
                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 1);

                // Ensure even downloaded, if there is coincident content, it is not duplicated.
                rts.Acquire(targetFolder);
                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 1);

                // Change the previous acquired content and ensure it is acquired again
                Directory.Move(acquiredContentFolder, acquiredContentFolder + "_old");

                rts.Acquire(targetFolder);

                Assert.True(Directory.EnumerateDirectories(targetFolder).Count() == 2);
            }
            finally
            {
                if (Directory.Exists(targetFolder))
                {
                    Directory.Delete(targetFolder, true);
                }
            }
        }
        public void TestRemoteSource_GetContent()
        {
            string drive   = Path.GetPathRoot(new Uri(typeof(TemplatePackageTests).Assembly.CodeBase).LocalPath);
            string testDir = Path.Combine(drive, $@"Temp\TestRts{Process.GetCurrentProcess().Id}_{Thread.CurrentThread.ManagedThreadId}");

            try
            {
                RemoteTemplatesSource rts = new RemoteTemplatesSource();
                rts.LoadConfig();
                var package = rts.Config.Latest;

                rts.Acquire(ref package);
                var contentInfo = rts.GetContent(package, testDir);

                Assert.True(Directory.Exists(contentInfo.Path));
            }
            finally
            {
                if (Directory.Exists(testDir))
                {
                    Directory.Delete(testDir, true);
                }
            }
        }