public void Save_DeletedWritingSystem_RemovesLdmlFile()
        {
            using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
            {
                var repo = new GlobalWritingSystemRepository(e.Path);
                var ws   = new WritingSystemDefinition("en-US");
                repo.Set(ws);
                repo.Save();
                Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.True);

                ws.MarkedForDeletion = true;
                repo.Save();
                Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.False);
            }
        }
 public void Save_UpdatedWritingSystem_UpdatesLdmlFile()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         var ws   = new WritingSystemDefinition("en-US");
         repo.Set(ws);
         repo.Save();
         DateTime modified = File.GetLastWriteTime(repo.GetFilePathFromLanguageTag("en-US"));
         // ensure that last modified timestamp changes
         Thread.Sleep(1000);
         ws.WindowsLcid = "test";
         repo.Save();
         Assert.That(File.GetLastWriteTime(repo.GetFilePathFromLanguageTag("en-US")), Is.Not.EqualTo(modified));
     }
 }
 public void Save_NewWritingSystem_CreatesLdmlFile()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         var ws   = new WritingSystemDefinition("en-US");
         repo.Set(ws);
         repo.Save();
         Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.True);
     }
 }
		public void Save_NewWritingSystem_CreatesLdmlFile()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo.Set(ws);
				repo.Save();
				Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.True);
			}
		}
 public void Count_LdmlAddedByAnotherRepo_ReturnsOne()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         Assert.That(repo2.Count, Is.EqualTo(0));
         var ws = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(File.Exists(repo1.GetFilePathFromLanguageTag("en-US")), Is.True);
         Assert.That(repo2.Count, Is.EqualTo(1));
     }
 }
 public void Get_LdmlAddedByAnotherRepo_ReturnsDefinition()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         Assert.That(() => repo2.Get("en-US"), Throws.TypeOf <ArgumentOutOfRangeException>());
         var ws = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(File.Exists(repo1.GetFilePathFromLanguageTag("en-US")), Is.True);
         Assert.That(repo2.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
     }
 }
Exemple #7
0
 public void AllWritingSystems_LdmlAddedByAnotherRepo_ReturnsDefinition()
 {
     using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         Assert.That(repo2.AllWritingSystems, Is.Empty);
         var ws = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(File.Exists(repo1.GetFilePathFromLanguageTag("en-US")), Is.True);
         Assert.That(repo2.AllWritingSystems.First().LanguageTag, Is.EqualTo("en-US"));
     }
 }
Exemple #8
0
 public void Save_ChangingIcuSort_DoesNotDuplicateInLdmlFile()
 {
     using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         var ws   = new WritingSystemDefinition("en-US");
         ws.Collations.Add(new IcuRulesCollationDefinition("standard")
         {
             IcuRules = "&b < a"
         });
         repo.Set(ws);
         repo.Save();
         // ensure that last modified timestamp changes
         Thread.Sleep(1000);
         ws.WindowsLcid = "test";
         repo.Save();
         AssertThatXmlIn.File(repo.GetFilePathFromLanguageTag("en-US")).HasSpecifiedNumberOfMatchesForXpath("/ldml/collations/collation", 1);
     }
 }
		public void Save_UpdatedWritingSystem_UpdatesLdmlFile()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo.Set(ws);
				repo.Save();
				DateTime modified = File.GetLastWriteTime(repo.GetFilePathFromLanguageTag("en-US"));
				// ensure that last modified timestamp changes
				Thread.Sleep(1000);
				ws.WindowsLcid = "test";
				repo.Save();
				Assert.That(File.GetLastWriteTime(repo.GetFilePathFromLanguageTag("en-US")), Is.Not.EqualTo(modified));
			}
		}
		public void Save_DeletedWritingSystem_RemovesLdmlFile()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo.Set(ws);
				repo.Save();
				Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.True);

				ws.MarkedForDeletion = true;
				repo.Save();
				Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.False);
			}
		}
		public void Count_LdmlAddedByAnotherRepo_ReturnsOne()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				Assert.That(repo2.Count, Is.EqualTo(0));
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(File.Exists(repo1.GetFilePathFromLanguageTag("en-US")), Is.True);
				Assert.That(repo2.Count, Is.EqualTo(1));
			}
		}
		public void Get_LdmlAddedByAnotherRepo_ReturnsDefinition()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				Assert.That(() => repo2.Get("en-US"), Throws.TypeOf<ArgumentOutOfRangeException>());
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(File.Exists(repo1.GetFilePathFromLanguageTag("en-US")), Is.True);
				Assert.That(repo2.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
			}
		}