Пример #1
0
 public void ThrowIfCannotCreateDestination()
 {
     Assert.Throws <ApplicationException>(() =>
                                          BackupMaker.BackupToExternal(BasilProject.GetPretendProjectDirectory(),
                                                                       "QQ:\\" + Path.GetRandomFileName(),
                                                                       _filesToBackup));
 }
Пример #2
0
        private static string CreateSingleWritingsystemsFileForEasyXslProcessing()
        {
            string pathToTempFile = Path.GetTempFileName();

            StreamWriter tempFileWriter = new StreamWriter(pathToTempFile);
            string       xmlHeader      = @"<?xml version=""1.0"" encoding=""utf-8""?>";

            tempFileWriter.WriteLine(xmlHeader);
            tempFileWriter.WriteLine("<root>");

            string pathToLdmlWritingSystemsFolder =
                BasilProject.GetPathToLdmlWritingSystemsFolder(BasilProject.Project.ProjectDirectoryPath);

            foreach (string fileName in Directory.GetFiles(pathToLdmlWritingSystemsFolder, "*.ldml"))
            {
                StreamReader ldmlFileStream = new StreamReader(fileName);
                string       line;
                while ((line = ldmlFileStream.ReadLine()) != null)
                {
                    if (line.Contains("<?xml"))
                    {
                        continue;
                    }
                    tempFileWriter.WriteLine(line);
                }
                ldmlFileStream.Close();
            }
            tempFileWriter.WriteLine("</root>");
            tempFileWriter.Close();
            return(pathToTempFile);
        }
Пример #3
0
 public void Setup()
 {
     WeSayProjectTestHelper.InitializeForTests();
     _destinationZip    = Path.Combine(Path.GetTempPath(), Path.GetTempFileName() + ".zip");
     _sourceProjectPath = BasilProject.GetPretendProjectDirectory();
     _backupMaker       = new BackupMaker();
     _filesToBackup     = WeSayWordsProject.GetFilesBelongingToProject(_sourceProjectPath);
 }
Пример #4
0
        public void TestFixtureSetUp()
        {
            _project = new WeSayWordsProject();
            _project.UiOptions.Language = "en";
            _project.LoadFromProjectDirectoryPath(BasilProject.GetPretendProjectDirectory());

            _project.Tasks = new List <ITask>();
        }
Пример #5
0
		public void LocalizedStringsDuringTests()
		{
			InitializeSampleProject();

			BasilProject project = new BasilProject();
			project.StringCatalogSelector = "th";
			project.LoadFromProjectDirectoryPath(_projectDirectory);
			Assert.AreEqual("deng", StringCatalog.Get("red"));
		}
Пример #6
0
        public static WeSayWordsProject InitializeForTests()
        {
            WeSayWordsProject project = new WeSayWordsProject();

            try
            {
                File.Delete(WeSayWordsProject.PathToPretendLiftFile);
            }
            catch (Exception) { }
            DirectoryInfo projectDirectory   = Directory.CreateDirectory(Path.GetDirectoryName(WeSayWordsProject.PathToPretendLiftFile));
            string        pathToLdmlWsFolder = BasilProject.GetPathToLdmlWritingSystemsFolder(projectDirectory.FullName);

            if (File.Exists(WeSayWordsProject.PathToPretendWritingSystemPrefs))
            {
                File.Delete(WeSayWordsProject.PathToPretendWritingSystemPrefs);
            }

            if (Directory.Exists(pathToLdmlWsFolder))
            {
                Directory.Delete(pathToLdmlWsFolder, true);
            }

            Palaso.Lift.Utilities.CreateEmptyLiftFile(WeSayWordsProject.PathToPretendLiftFile, "InitializeForTests()", true);

            //setup writing systems
            Directory.CreateDirectory(pathToLdmlWsFolder);
            IWritingSystemRepository wsc = LdmlInFolderWritingSystemRepository.Initialize(
                pathToLdmlWsFolder,
                OnMigrationHandler,
                OnWritingSystemLoadProblem,
                WritingSystemCompatibility.Flex7V0Compatible
                );

            IWritingSystemDefinition _ws1 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.VernacularIdForTest);

            _ws1.DefaultFontName = "Arial";
            _ws1.DefaultFontSize = 30;
            wsc.Set(_ws1);
            IWritingSystemDefinition _ws2 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest);

            _ws2.DefaultFontName = new Font(FontFamily.GenericSansSerif, 12).Name;
            _ws2.DefaultFontSize = new Font(FontFamily.GenericSansSerif, 12).Size;
            wsc.Set(_ws2);
            IWritingSystemDefinition _ws3 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest);

            _ws3.DefaultFontName = "Arial";
            _ws3.DefaultFontSize = 15;
            wsc.Set(_ws3);


            wsc.Save();

            project.SetupProjectDirForTests(WeSayWordsProject.PathToPretendLiftFile);
            project.BackupMaker = null;            //don't bother. Modern tests which might want to check backup won't be using this old approach anyways.
            return(project);
        }
Пример #7
0
        public void LocalizedStringsFromPretendSample()
        {
            InitializeSampleProject();
            BasilProject project = new BasilProject();

            project.UiOptions.Language = "en";
            project.LoadFromProjectDirectoryPath(_projectDirectory);

            Assert.AreEqual("red", StringCatalog.Get("red"));
        }
Пример #8
0
        public void ProjectFilesTouched()
        {
            _window.OpenProject(BasilProject.GetPretendProjectDirectory());
            string   p      = WeSayWordsProject.Project.PathToConfigFile;
            DateTime before = File.GetLastWriteTime(p);

            _mainWindowTester.Close();
            DateTime after = File.GetLastWriteTime(p);

            Assert.AreNotEqual(before, after);
        }
Пример #9
0
 public void WalkTabsAfterOpeningPretendProject()
 {
     _window.OpenProject(BasilProject.GetPretendProjectDirectory());
     //create or overwrite the tasks with our stored resource
     //            File.Delete(WeSayWordsProject.Project.PathToProjectTaskInventory);
     //            StreamWriter writer = File.CreateText(WeSayWordsProject.Project.PathToProjectTaskInventory);
     //            writer.Write(TestResources.tasks);
     //            writer.Close();
     File.Copy(
         Path.Combine(WeSayWordsProject.Project.ApplicationTestDirectory,
                      "PRETEND.WeSayConfig"),
         WeSayWordsProject.Project.PathToConfigFile,
         true);
     WalkTopLevelTabs();
 }
        public void WalkTabsAfterOpeningPretendProject()
        {
            _window.OpenProject(BasilProject.GetPretendProjectDirectory());
            File.Copy(
                Path.Combine(WeSayWordsProject.Project.ApplicationTestDirectory,
                             "PRETEND.WeSayConfig"),
                WeSayWordsProject.Project.PathToConfigFile,
                true);

            ToolStrip toolstrip = (ToolStrip)_window.Controls.Find("_areasToolStrip", true)[0];

            foreach (ToolStripButton button in toolstrip.Items)
            {
                button.PerformClick();
            }
        }
Пример #11
0
 public void ReadListFile_NonExistantSemanticDomainFile_Throws()
 {
     using (var projectDirectory = new TemporaryFolder())
     {
         if (File.Exists(Path.Combine(BasilProject.GetPretendProjectDirectory(), "SemDom.xml")))
         {
             File.Delete(Path.Combine(BasilProject.GetPretendProjectDirectory(), "SemDom.xml"));
         }
         //setting up a minimal WeSay project with a config file that contains an id for a nonexistent writing system
         var project       = new WeSayWordsProject();
         var localizedList = new LocalizedListParser();
         localizedList.ApplicationCommonDirectory = BasilProject.GetPretendProjectDirectory();
         localizedList.PathToWeSaySpecificFilesDirectoryInProject = projectDirectory.Path;
         localizedList.SemanticDomainWs = "en";
         Assert.Throws <ApplicationException>(() => localizedList.ReadListFile());
     }
 }
        public static bool Create(string pathToNewDirectory, string pathToSourceLift)
        {
            try
            {
                Logger.WriteEvent(@"Starting Project creation from " + pathToSourceLift);

                if (!ReportIfLocked(pathToSourceLift))
                {
                    return(false);
                }

                RequireThat.Directory(pathToNewDirectory).DoesNotExist();

                Directory.CreateDirectory(pathToNewDirectory);

                CopyOverLiftFile(pathToSourceLift, pathToNewDirectory);

                CopyOverRangeFileIfExists(pathToSourceLift, pathToNewDirectory);

                CopyOverLdmlFiles(pathToSourceLift, BasilProject.GetPathToLdmlWritingSystemsFolder(pathToNewDirectory));

                File.Create(Path.Combine(pathToNewDirectory, ".newlycreatedfromFLEx")).Dispose();

                //The config file is created on project open when all of the orphaned writing systems have been identified.

                Logger.WriteEvent(@"Finished Importing");
                return(true);
            }
            catch (Exception e)
            {
                Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "WeSay was unable to finish importing that LIFT file.  If you cannot fix the problem yourself, please zip and send the exported folder to issues (at) wesay (dot) org");
                try
                {
                    Logger.WriteEvent(@"Removing would-be target directory");
                    Directory.Delete(pathToNewDirectory, true);
                }
                catch (Exception)
                {
                    //swallow
                }
                return(false);
            }
        }
Пример #13
0
        [Test]         //, ExpectedException(typeof(FormsTestAssertionException))]
        public void AfterCreateProjectAndQuitFilesExist()
        {
            List <string> paths = new List <string>();

            _window.CreateAndOpenProject(_projectFolder, "th", "Thai");
            paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "th.ldml"));
            paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "en.ldml"));
            //paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "es.ldml"));
            //paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "fr.ldml"));
            //paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "id.ldml"));
            //paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "th.ldml"));
            //paths.Add(Path.Combine(BasilProject.GetPathToLdmlWritingSystemsFolder(_projectFolder), "tpi.ldml"));
            paths.Add(WeSayWordsProject.Project.PathToConfigFile);
            //paths.Add(WeSayWordsProject.Project.PathToRepository);
            _mainWindowTester.Close();
            foreach (string p in paths)
            {
                if (!File.Exists(p))
                {
                    Assert.Fail("Did not create " + p);
                }
            }
        }
Пример #14
0
		public void LocalizedStringsFromPretendSample()
		{
			InitializeSampleProject();
			BasilProject project = new BasilProject();
			project.StringCatalogSelector = "en";
			project.LoadFromProjectDirectoryPath(_projectDirectory);

			Assert.AreEqual("red", StringCatalog.Get("red"));
		}