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));
     }
 }
Ejemplo n.º 2
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_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);
     }
 }
Ejemplo n.º 5
0
 public void Get_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.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"));
     }
 }
 public void Get_LdmlRemovedByAnotherRepo_Throws()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(repo1.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
         repo2.Remove("en-US");
         Assert.That(() => repo1.Get("en-US"), Throws.TypeOf <ArgumentOutOfRangeException>());
     }
 }
 public void AllWritingSystems_LdmlRemovedByAnotherRepo_ReturnsEmpty()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(repo1.AllWritingSystems, Is.Not.Empty);
         repo2.Remove("en-US");
         Assert.That(repo1.AllWritingSystems, Is.Empty);
     }
 }
 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 Count_LdmlRemovedByAnotherRepo_ReturnsZero()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(repo1.Count, Is.EqualTo(1));
         repo2.Remove("en-US");
         Assert.That(repo1.Count, Is.EqualTo(0));
     }
 }
Ejemplo n.º 10
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"));
     }
 }
 public void Get_UpdatedLdmlRemovedByAnotherRepo_ReturnUpdatedDefinition()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(repo1.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
         repo2.Remove("en-US");
         ws.WindowsLcid = "test";
         Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test"));
     }
 }
 public void AllWritingSystems_LdmlUpdatedByAnotherRepo_ReturnsUpdatedDefinition()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(ws.WindowsLcid, Is.Empty);
         ws             = repo2.Get("en-US");
         ws.WindowsLcid = "test";
         repo2.Save();
         Assert.That(repo2.AllWritingSystems.First().WindowsLcid, Is.EqualTo("test"));
     }
 }
Ejemplo n.º 13
0
 public void Get_UpdatedLdmlUpdatedByAnotherRepo_ReturnLastUpdatedDefinition()
 {
     using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(repo1.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
         WritingSystemDefinition ws2 = repo2.Get("en-US");
         ws2.WindowsLcid = "test2";
         repo2.Save();
         ws.WindowsLcid = "test1";
         Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test1"));
     }
 }
Ejemplo n.º 14
0
        public void Get_CaseDifferingWritingSystems_DoesNotThrow(string id)
        {
            using (var temporaryFolder = CreateTemporaryFolder("Get_CaseDifferingWritingSystems_DoesNotThrow"))
            {
                // Setup
                var repo = new GlobalWritingSystemRepository(temporaryFolder.Path);
                var ws   = new WritingSystemDefinition("en-US");
                repo.Set(ws);
                repo.Save();
                // Now we simulate that the user did a S/R which added a WS that differs by case
                File.Copy(Path.Combine(temporaryFolder.Path, "3", ws.Id + ".ldml"),
                          Path.Combine(temporaryFolder.Path, "3", ws.Id.ToLower() + ".ldml"));

                // SUT/Verify
                Assert.That(() => repo.Get(id), Throws.Nothing);
            }
        }
 public void Get_LdmlUpdatedByAnotherRepo_ReturnsUpdatedDefinition()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo1 = new GlobalWritingSystemRepository(e.Path);
         var repo2 = new GlobalWritingSystemRepository(e.Path);
         var ws    = new WritingSystemDefinition("en-US");
         repo1.Set(ws);
         repo1.Save();
         Assert.That(ws.WindowsLcid, Is.Empty);
         // ensure that last modified timestamp changes
         Thread.Sleep(1000);
         ws             = repo2.Get("en-US");
         ws.WindowsLcid = "test";
         repo2.Save();
         Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test"));
     }
 }
Ejemplo n.º 16
0
        public void Remove_CaseDifferingWritingSystems_DoesNotThrow(string id)
        {
            using (var temporaryFolder = CreateTemporaryFolder("Remove_CaseDifferingWritingSystems_DoesNotThrow"))
            {
                // Setup
                var repo = new GlobalWritingSystemRepository(temporaryFolder.Path);
                var ws   = new WritingSystemDefinition("en-US");
                repo.Set(ws);
                repo.Save();

                // SUT
                Assert.That(() => repo.Remove(id), Throws.Nothing);

                // Verify
                Assert.That(repo.Contains("en-US"), Is.False);
                Assert.That(repo.Contains("en-us"), Is.False);
                Assert.That(File.Exists(Path.Combine(temporaryFolder.Path, "3", "en-US.ldml")),
                            Is.False);
                Assert.That(File.Exists(Path.Combine(temporaryFolder.Path, "3", "en-us.ldml")),
                            Is.False);
            }
        }
        public void AllWritingSystems_LdmlCheckingSetEmptyandGetWSId()
        {
            using (var tf = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
            {
                var repo1 = new GlobalWritingSystemRepository(tf.Path);
                var repo2 = new GlobalWritingSystemRepository(tf.Path);

                var ws = new WritingSystemDefinition("en-US");
                repo1.Set(ws);
                repo1.Save();
                Assert.That(ws.WindowsLcid, Is.Empty);
                // ensure that last modified timestamp changes
                Thread.Sleep(1000);
                ws             = repo2.Get("en-US");
                ws.WindowsLcid = "test";
                // Make an arbitrary change to force a save of the ldml file.
                ws.Id = string.Empty;
                repo2.Save();
                Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test"));
                Assert.That(ws.IsChanged, Is.False);
                Assert.AreEqual(ws.Id, "en-US");
            }
        }
Ejemplo n.º 18
0
        public void AllWritingSystems_LdmlCheckingSetEmptyCanNotSave()
        {
            using (var tf = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
            {
                var repo1 = new GlobalWritingSystemRepository(tf.Path);
                var repo2 = new GlobalWritingSystemRepository(tf.Path);

                var ws = new WritingSystemDefinition("en-US");
                repo1.Set(ws);
                repo1.Save();
                Assert.That(ws.WindowsLcid, Is.Empty);
                // ensure that last modified timestamp changes
                Thread.Sleep(1000);
                ws             = repo2.Get("en-US");
                ws.WindowsLcid = "test";
                // a ws with an empty Id is assumed to be new, we can't save it if the LanguageTag is already found
                // in the repo.
                ws.Id = string.Empty;
                Assert.That(repo2.CanSet(ws), Is.False, "A ws with an empty ID will not save if the LanguageTag matches an existing ws");
                repo2.Save();
                Assert.That(repo1.Get("en-US").WindowsLcid, Is.Not.EqualTo("test"), "Changes should not have been saved.");
            }
        }
		public void Get_LdmlRemovedByAnotherRepo_Throws()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(repo1.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
				repo2.Remove("en-US");
				Assert.That(() => repo1.Get("en-US"), Throws.TypeOf<ArgumentOutOfRangeException>());
			}
		}
		public void Get_UpdatedLdmlUpdatedByAnotherRepo_ReturnLastUpdatedDefinition()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(repo1.Get("en-US").LanguageTag, Is.EqualTo("en-US"));
				WritingSystemDefinition ws2 = repo2.Get("en-US");
				ws2.WindowsLcid = "test2";
				repo2.Save();
				ws.WindowsLcid = "test1";
				Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test1"));
			}
		}
		public void AllWritingSystems_LdmlRemovedByAnotherRepo_ReturnsEmpty()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(repo1.AllWritingSystems, Is.Not.Empty);
				repo2.Remove("en-US");
				Assert.That(repo1.AllWritingSystems, Is.Empty);
			}
		}
		public void AllWritingSystems_LdmlUpdatedByAnotherRepo_ReturnsUpdatedDefinition()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(ws.WindowsLcid, Is.Empty);
				ws = repo2.Get("en-US");
				ws.WindowsLcid = "test";
				repo2.Save();
				Assert.That(repo2.AllWritingSystems.First().WindowsLcid, Is.EqualTo("test"));
			}
		}
		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 Count_LdmlRemovedByAnotherRepo_ReturnsZero()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(repo1.Count, Is.EqualTo(1));
				repo2.Remove("en-US");
				Assert.That(repo1.Count, Is.EqualTo(0));
			}
		}
		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 Get_LdmlUpdatedByAnotherRepo_ReturnsUpdatedDefinition()
		{
			using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
			{
				var repo1 = new GlobalWritingSystemRepository(e.Path);
				var repo2 = new GlobalWritingSystemRepository(e.Path);
				var ws = new WritingSystemDefinition("en-US");
				repo1.Set(ws);
				repo1.Save();
				Assert.That(ws.WindowsLcid, Is.Empty);
				// ensure that last modified timestamp changes
				Thread.Sleep(1000);
				ws = repo2.Get("en-US");
				ws.WindowsLcid = "test";
				repo2.Save();
				Assert.That(repo1.Get("en-US").WindowsLcid, Is.EqualTo("test"));
			}
		}