Ejemplo n.º 1
0
        public void AllWritingSystems_LdmlCheckingSetEmptyCanNotSave()
        {
            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";
                // 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.");
            }
        }